Collections

System.Collections classes

The classes in the System.Collections namespace do not store elements as specifically typed objects, but as objects of type Object.

ClassDescription

ArrayList

Represents an array of objects whose size is dynamically increased as required.

Hashtable

Represents a collection of key/value pairs that are organized based on the hash code of the key.

Queue

Represents a first in, first out (FIFO) collection of objects.

Stack

Represents a last in, first out (LIFO) collection of objects.

The System.Collections.Specialized namespace provides specialized and strongly typed collection classes, such as string-only collections and linked-list and hybrid dictionaries.

System.Collections.Generic classes

A generic collection enforces strong typing by allowing only the desired data type to be added. A generic collection is useful when every item in the collection has the same data type.

ClassDescription

Dictionary<TKey,TValue>

Represents a collection of key/value pairs that are organized based on the key.

List<T>

Represents a list of objects that can be accessed by index. Provides methods to search, sort, and modify lists.

Queue<T>

Represents a first in, first out (FIFO) collection of objects.

Stack<T>

Represents a last in, first out (LIFO) collection of objects.

Dictionary<TKey, TValue>()

Dictionary internally stores object in an array, but unlike a list, where objects are added at the end of the array (or at the index), the index is calculated using a hash function.

List<T>

List internally uses arrays, if it becomes full it'll create a new larger array and copy content from the older array to the new one.

System.Collections.Concurrent classes

A concurrent collection provide efficient thread-safe operations for accessing collection items from multiple threads.

Last updated