ASP.NET has many collection classes for managing collections of items. Most of these collections are in the System.Collections, System.Collections.Generic, and System.Collections.Concurrent namespaces. 

The proper collection depends on your data storage, retrieval, ordering, and thread safety needs. 

Here are some common ASP.NET collection types:'

 

Non-Generic System.Collections These collections can store items of any type (object). They are less type-safe than generic collections, Since they're less type-safe than generic collections, therefore casting errors can occur.

  • ArrayList: A dynamic array that can resize as needed. It helps when you don't know the collection size.
  • Hashtable: Stores key-value pairs where keys are unique and are used for fast lookups using a hash code. 
  • Queue. Represents a first-in, first-out (FIFO) collection. Items are added at the end (Enqueue) and removed from the beginning (Dequeue). 
  • Stack: Represents a last-in, first-out (LIFO) collection. Items are added at the top (Push) and removed from the top (Pop). 
  • SortedList: Similar to Hashtable but the key-value pairs are sorted by the keys. 

 

 

Generic Collections - 
Namespace: System.Collections.Generic
You select the type of items these type-safe collections will hold. This eliminates casting and improves compile-time type verification and speed.

  • Strongly typed dynamic array List<T>: A strongly typed dynamic array, offering better performance and type safety than ArrayList
  • Use Dictionary<TKey, TValue> for fast lookups using unique keys in a highly typed Hashtable.
  • Queue<T>: Strongly typed FIFO collection.
  • SortedList<TKey, TValue>:  A strongly typed collection of key-value pairs sorted by key.
  • Stack<T>: Strongly typed LIFO collection.
  • Stack<T>: Strongly typed LIFO collection.
  • SortedDictionary<TKey, TValue>: Similar to SortedList<TKey, TValue> but implemented as a binary search tree, offering different performance characteristics for insertions and deletions.
  • HashSet<T>: An unordered collection that contains only unique elements. It's efficient for checking if an item exists in the collection and for set operations (union, intersection, etc.).
  • SortedSet<T>: A collection that contains unique elements and keeps them sorted.
  • LinkedList<T>: A doubly linked list, where each element points to the next and previous elements. It's efficient for insertions and deletions in the middle of the list.  

Related Question