C#C
C#3y ago
krixsick

❔ ✅ Lists vs arrays vs ArrayLists and jagged arrays and dictionaries vs hashtables

Hello! I'm currently still learning more about collections in C# and I came across about non-generic and generic. I think I understand the difference but correct me if I'm wrong is that generic collections are like specialized containers that can hold a collection of objects, but they are designed to work with a specific type of objects. On the other hand, non-generic are like containers that can hold different types of objects. They are not specific about the type of objects they can store. Because of this, ArrayList, Hashtable, and SortedList are considered as non-generic collections and Arrays, dictionaries, Lists, Hashsets and other stuff are considered generic.

Now I'm still new to learning all of this so it probably isn't smart of me to find the difference between all of these and learn each one step by step. But currently some questions I have is

  1. how dictionaries are considered a generic collection since can't they store strings and integers (my guess because python dictionaries can store ints and strings)
  2. The difference between Arrays, Lists, and an ArrayList. I feel like lists basically outclass an array but the only difference I kinda see is when you initialize them. For an array if you know the amount of entries you can state that and create an array that can only hold like 5 entries. (int [] grades = new int[5];). But im learning arraylists right now and they seem very similar to lists.
  3. Are jagged arrays useful? So far I dont think my skills are good enough to use jagged arrays efficiently so I was wondering if they're actually beneficial. Since I am not good at C# lol
  4. I know the difference between hashtables and dictionaries is that one is generic and non-generic, but im just confused on how they both aren't considered non-generic
Was this page helpful?