C# collection

h‮//:sptt‬www.theitroad.com

In C#, a collection is a group of related objects or values that can be manipulated as a single unit. Collections are used to store, retrieve, manipulate, and modify data in an organized way. There are many built-in collection classes in C# that provide various features and functionalities.

Some of the commonly used collection classes in C# are:

  1. List<T> - A generic list that can store elements of any type T.

  2. Dictionary<TKey, TValue> - A generic key-value pair collection that allows you to store values based on unique keys.

  3. Stack<T> - A generic collection that allows you to add and remove elements in a Last-In-First-Out (LIFO) manner.

  4. Queue<T> - A generic collection that allows you to add and remove elements in a First-In-First-Out (FIFO) manner.

  5. HashSet<T> - A generic collection that allows you to store unique elements.

  6. LinkedList<T> - A generic collection that allows you to store elements in a linked list data structure.

  7. ObservableCollection<T> - A collection that provides notifications when the collection is changed.

  8. SortedList<TKey, TValue> - A generic collection that stores key-value pairs in sorted order based on the keys.

  9. SortedSet<T> - A generic collection that stores unique elements in sorted order.

These collection classes provide various methods and properties to manipulate and access the data stored in them. They can be used to simplify complex data structures and algorithms, and can help to improve the performance of your code.