Back In the print window choose "Save as PDF" as the destination
NOTE.CS

Collections and Generics

1 topic · 28 Nov 2026
1

Collections and Generics

C#
CollectionUse
List<T>Dynamic array
Dictionary<K,V>Key → value (hash table)
HashSet<T>Unique items
Queue<T> / Stack<T>FIFO / LIFO
Array (T[])Fixed size
C#
var nums = new List<int> { 5, 2, 8 };
nums.Add(1);
nums.Sort();                       // 1 2 5 8

var ages = new Dictionary<string, int>();
ages["Rahim"] = 25;
if (ages.TryGetValue("Rahim", out int age))
    Console.WriteLine(age);

// generic method
static T Max<T>(T a, T b) where T : IComparable<T> => a.CompareTo(b) > 0 ? a : b;