System.Collections.Generic Namespace

Contains interfaces and classes that define generic collections, which allow users to create strongly typed collections that provide better type safety and performance than non-generic strongly typed collections.

Classes

Name Description
CollectionExtensions

Provides extension methods for generic collections.

Comparer

Provides a base class for implementations of the IComparer generic interface.

Dictionary.KeyCollection

Represents the collection of keys in a Dictionary. This class cannot be inherited.

Dictionary.ValueCollection

Represents the collection of values in a Dictionary. This class cannot be inherited.

Dictionary

Represents a collection of keys and values.

EqualityComparer

Provides a base class for implementations of the IEqualityComparer generic interface.

HashSet

Represents a set of values.

KeyedByTypeCollection

Provides a collection whose items are types that serve as keys.

KeyNotFoundException

The exception that is thrown when the key specified for accessing an element in a collection does not match any key in the collection.

KeyValuePair

Creates instances of the KeyValuePair struct.

LinkedList

Represents a doubly linked list.

LinkedListNode

Represents a node in a LinkedList. This class cannot be inherited.

List

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

OrderedDictionary.KeyCollection

Represents the collection of keys in a OrderedDictionary.

OrderedDictionary.ValueCollection

Represents the collection of values in a OrderedDictionary.

OrderedDictionary

Represents a collection of key/value pairs that are accessible by the key or index.

PriorityQueue.UnorderedItemsCollection

Enumerates the contents of a PriorityQueue, without any ordering guarantees.

PriorityQueue

Represents a collection of items that have a value and a priority. On dequeue, the item with the lowest priority value is removed.

Queue

Represents a first-in, first-out collection of objects.

ReferenceEqualityComparer

An IEqualityComparer that uses reference equality (ReferenceEquals(Object, Object)) instead of value equality (Equals(Object)) when comparing two object instances.

SortedDictionary.KeyCollection

Represents the collection of keys in a SortedDictionary. This class cannot be inherited.

SortedDictionary.ValueCollection

Represents the collection of values in a SortedDictionary. This class cannot be inherited.

SortedDictionary

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

SortedList

Represents a collection of key/value pairs that are sorted by key based on the associated IComparer implementation.

SortedSet

Represents a collection of objects that is maintained in sorted order.

Stack

Represents a variable size last-in-first-out (LIFO) collection of instances of the same specified type.

SynchronizedCollection

Provides a thread-safe collection that contains objects of a type specified by the generic parameter as elements.

SynchronizedKeyedCollection

Provides a thread-safe collection that contains objects of a type specified by a generic parameter and that are grouped by keys.

SynchronizedReadOnlyCollection

Provides a thread-safe, read-only collection that contains objects of a type specified by the generic parameter as elements.

Structs

Name Description
Dictionary.AlternateLookup

Provides a type that can be used to perform operations on a Dictionary using a TAlternateKey as a key instead of a TKey.

Dictionary.Enumerator

Enumerates the elements of a Dictionary.

Dictionary.KeyCollection.Enumerator

Enumerates the elements of a Dictionary.KeyCollection.

Dictionary.ValueCollection.Enumerator

Enumerates the elements of a Dictionary.ValueCollection.

HashSet.AlternateLookup

Provides a type that can be used to perform operations on a HashSet using a TAlternate instead of a T.

HashSet.Enumerator

Enumerates the elements of a HashSet object.

KeyValuePair

Defines a key/value pair that can be set or retrieved.

LinkedList.Enumerator

Enumerates the elements of a LinkedList.

List.Enumerator

Enumerates the elements of a List.

OrderedDictionary.Enumerator

Enumerates the elements of a OrderedDictionary.

OrderedDictionary.KeyCollection.Enumerator

Enumerates the elements of a OrderedDictionary.KeyCollection.

OrderedDictionary.ValueCollection.Enumerator

Enumerates the elements of a OrderedDictionary.ValueCollection.

PriorityQueue.UnorderedItemsCollection.Enumerator

Enumerates the element and priority pairs of a PriorityQueue, without any ordering guarantees.

Queue.Enumerator

Enumerates the elements of a Queue.

SortedDictionary.Enumerator

Enumerates the elements of a SortedDictionary.

SortedDictionary.KeyCollection.Enumerator

Enumerates the elements of a SortedDictionary.KeyCollection.

SortedDictionary.ValueCollection.Enumerator

Enumerates the elements of a SortedDictionary.ValueCollection.

SortedSet.Enumerator

Enumerates the elements of a SortedSet object.

Stack.Enumerator

Enumerates the elements of a Stack.

Interfaces

Name Description
IAlternateEqualityComparer

Implemented by an IEqualityComparer to support comparing a TAlternate instance with a T instance.

IAsyncEnumerable

Exposes an enumerator that provides asynchronous iteration over values of a specified type.

IAsyncEnumerator

Supports a simple asynchronous iteration over a generic collection.

ICollection

Defines methods to manipulate generic collections.

IComparer

Defines a method that a type implements to compare two objects.

IDictionary

Represents a generic collection of key/value pairs.

IEnumerable

Exposes the enumerator, which supports a simple iteration over a collection of a specified type.

IEnumerator

Supports a simple iteration over a generic collection.

IEqualityComparer

Defines methods to support the comparison of objects for equality.

IList

Represents a collection of objects that can be individually accessed by index.

IReadOnlyCollection

Represents a strongly-typed, read-only collection of elements.

IReadOnlyDictionary

Represents a generic read-only collection of key/value pairs.

IReadOnlyList

Represents a read-only collection of elements that can be accessed by index.

IReadOnlySet

Provides a readonly abstraction of a set.

ISet

Provides the base interface for the abstraction of sets.

Remarks

Many of the generic collection types are direct analogs of nongeneric types. Dictionary is a generic version of Hashtable; it uses the generic structure KeyValuePair for enumeration instead of DictionaryEntry. List is a generic version of ArrayList. There are generic Queue and Stack classes that correspond to the nongeneric versions. There are generic and nongeneric versions of SortedList. Both versions are hybrids of a dictionary and a list. The SortedDictionary generic class is a pure dictionary and has no nongeneric counterpart. The LinkedList generic class is a true linked list and has no nongeneric counterpart.

See also