This section provides a comprehensive overview of the System.Collections.Generic namespace.
Here's a breakdown of the important classes in System.Collections.Generic:
Example using List
System.Collections.Generic.List myList = new System.Collections.Generic.List() {1, 2, 3, 4, 5};
Console.WriteLine(myList);
Example using Dictionary
System.Collections.Generic.Dictionary myDict = new System.Collections.Generic.Dictionary() {
{"name", 1},
{"age", 30},
{"city", "New York"}
};
Console.WriteLine(myDict);
Example using LinkedList
System.Collections.Generic.LinkedList myList = new System.Collections.Generic.LinkedList() {1, 2, 3, 4, 5};
Console.WriteLine(myList);
Example using Queue
System.Collections.Generic.Queue myQueue = new System.Collections.Generic.Queue() {1, 2, 3, 4, 5};
Console.WriteLine(myQueue);
Example using HashSet
System.Collections.Generic.HashSet mySet = new System.Collections.Generic.HashSet() {
"apple", "banana", "cherry"
};
Console.WriteLine(mySet);
Example using SortedSet
System.Collections.Generic.SortedSet mySet = new System.Collections.Generic.SortedSet() {
1, 2, 3, 4, 5
};
Console.WriteLine(mySet);
See the full documentation: