Επεξεργασία

Κοινή χρήση μέσω


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

CollectionExtensions

Provides extension methods for generic collections.

Comparer<T>

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

Dictionary<TKey,TValue>.KeyCollection

Represents the collection of keys in a Dictionary<TKey,TValue>. This class cannot be inherited.

Dictionary<TKey,TValue>.ValueCollection

Represents the collection of values in a Dictionary<TKey,TValue>. This class cannot be inherited.

Dictionary<TKey,TValue>

Represents a collection of keys and values.

EqualityComparer<T>

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

HashSet<T>

Represents a set of values.

KeyedByTypeCollection<TItem>

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<TKey,TValue> struct.

LinkedList<T>

Represents a doubly linked list.

LinkedListNode<T>

Represents a node in a LinkedList<T>. This class cannot be inherited.

List<T>

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

OrderedDictionary<TKey,TValue>.KeyCollection

Represents the collection of keys in a OrderedDictionary<TKey,TValue>.

OrderedDictionary<TKey,TValue>.ValueCollection

Represents the collection of values in a OrderedDictionary<TKey,TValue>.

OrderedDictionary<TKey,TValue>

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

PriorityQueue<TElement,TPriority>.UnorderedItemsCollection

Enumerates the contents of a PriorityQueue<TElement,TPriority>, without any ordering guarantees.

PriorityQueue<TElement,TPriority>

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

Queue<T>

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

ReferenceEqualityComparer

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

SortedDictionary<TKey,TValue>.KeyCollection

Represents the collection of keys in a SortedDictionary<TKey,TValue>. This class cannot be inherited.

SortedDictionary<TKey,TValue>.ValueCollection

Represents the collection of values in a SortedDictionary<TKey,TValue>. This class cannot be inherited.

SortedDictionary<TKey,TValue>

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

SortedList<TKey,TValue>

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

SortedSet<T>

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

Stack<T>

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

SynchronizedCollection<T>

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

SynchronizedKeyedCollection<K,T>

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

SynchronizedReadOnlyCollection<T>

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

Structs

Dictionary<TKey,TValue>.AlternateLookup<TAlternateKey>

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

Dictionary<TKey,TValue>.Enumerator

Enumerates the elements of a Dictionary<TKey,TValue>.

Dictionary<TKey,TValue>.KeyCollection.Enumerator

Enumerates the elements of a Dictionary<TKey,TValue>.KeyCollection.

Dictionary<TKey,TValue>.ValueCollection.Enumerator

Enumerates the elements of a Dictionary<TKey,TValue>.ValueCollection.

HashSet<T>.AlternateLookup<TAlternate>

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

HashSet<T>.Enumerator

Enumerates the elements of a HashSet<T> object.

KeyValuePair<TKey,TValue>

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

LinkedList<T>.Enumerator

Enumerates the elements of a LinkedList<T>.

List<T>.Enumerator

Enumerates the elements of a List<T>.

OrderedDictionary<TKey,TValue>.Enumerator

Enumerates the elements of a OrderedDictionary<TKey,TValue>.

OrderedDictionary<TKey,TValue>.KeyCollection.Enumerator

Enumerates the elements of a OrderedDictionary<TKey,TValue>.KeyCollection.

OrderedDictionary<TKey,TValue>.ValueCollection.Enumerator

Enumerates the elements of a OrderedDictionary<TKey,TValue>.ValueCollection.

PriorityQueue<TElement,TPriority>.UnorderedItemsCollection.Enumerator

Enumerates the element and priority pairs of a PriorityQueue<TElement,TPriority>, without any ordering guarantees.

Queue<T>.Enumerator

Enumerates the elements of a Queue<T>.

SortedDictionary<TKey,TValue>.Enumerator

Enumerates the elements of a SortedDictionary<TKey,TValue>.

SortedDictionary<TKey,TValue>.KeyCollection.Enumerator

Enumerates the elements of a SortedDictionary<TKey,TValue>.KeyCollection.

SortedDictionary<TKey,TValue>.ValueCollection.Enumerator

Enumerates the elements of a SortedDictionary<TKey,TValue>.ValueCollection.

SortedSet<T>.Enumerator

Enumerates the elements of a SortedSet<T> object.

Stack<T>.Enumerator

Enumerates the elements of a Stack<T>.

Interfaces

IAlternateEqualityComparer<TAlternate,T>

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

IAsyncEnumerable<T>

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

IAsyncEnumerator<T>

Supports a simple asynchronous iteration over a generic collection.

ICollection<T>

Defines methods to manipulate generic collections.

IComparer<T>

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

IDictionary<TKey,TValue>

Represents a generic collection of key/value pairs.

IEnumerable<T>

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

IEnumerator<T>

Supports a simple iteration over a generic collection.

IEqualityComparer<T>

Defines methods to support the comparison of objects for equality.

IList<T>

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

IReadOnlyCollection<T>

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

IReadOnlyDictionary<TKey,TValue>

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

IReadOnlyList<T>

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

IReadOnlySet<T>

Provides a readonly abstraction of a set.

ISet<T>

Provides the base interface for the abstraction of sets.

Remarks

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

See also