System.Collections.Generic 命名空间

System.Collections.Generic 命名空间包含定义泛型集合的接口和类,用户可以使用泛型集合来创建强类型集合,这种集合能提供比非泛型强类型集合更好的类型安全性和性能。 The 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.

CollectionExtensions
Comparer<T>

IComparer<T> 泛型接口的实现提供基类。Provides a base class for implementations of the IComparer<T> generic interface.

Dictionary<TKey,TValue>.KeyCollection

表示 Dictionary<TKey,TValue> 中键的集合。Represents the collection of keys in a Dictionary<TKey,TValue>. 此类不能被继承。This class cannot be inherited.

Dictionary<TKey,TValue>.ValueCollection

表示 Dictionary<TKey,TValue> 中值的集合。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>

IEqualityComparer<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
LinkedList<T>

表示双向链接列表。Represents a doubly linked list.

LinkedListNode<T>

表示 LinkedList<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.

Queue<T>

表示对象的先进先出集合。Represents a first-in, first-out collection of objects.

SortedDictionary<TKey,TValue>.KeyCollection

表示 SortedDictionary<TKey,TValue> 中键的集合。Represents the collection of keys in a SortedDictionary<TKey,TValue>. 此类不能被继承。This class cannot be inherited.

SortedDictionary<TKey,TValue>.ValueCollection

表示 SortedDictionary<TKey,TValue> 中值的集合。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>

表示基于相关的 IComparer<T> 实现按键进行排序的键/值对的集合。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>

表示相同指定类型的实例可变大小的后进先出 (LIFO) 集合。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.

结构

Dictionary<TKey,TValue>.Enumerator

枚举 Dictionary<TKey,TValue> 的元素。Enumerates the elements of a Dictionary<TKey,TValue>.

Dictionary<TKey,TValue>.KeyCollection.Enumerator

枚举 Dictionary<TKey,TValue>.KeyCollection 的元素。Enumerates the elements of a Dictionary<TKey,TValue>.KeyCollection.

Dictionary<TKey,TValue>.ValueCollection.Enumerator

枚举 Dictionary<TKey,TValue>.ValueCollection 的元素。Enumerates the elements of a Dictionary<TKey,TValue>.ValueCollection.

HashSet<T>.Enumerator

枚举 HashSet<T> 对象的元素。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

枚举 LinkedList<T> 的元素。Enumerates the elements of a LinkedList<T>.

List<T>.Enumerator

枚举 List<T> 的元素。Enumerates the elements of a List<T>.

Queue<T>.Enumerator

枚举 Queue<T> 的元素。Enumerates the elements of a Queue<T>.

SortedDictionary<TKey,TValue>.Enumerator

枚举 SortedDictionary<TKey,TValue> 的元素。Enumerates the elements of a SortedDictionary<TKey,TValue>.

SortedDictionary<TKey,TValue>.KeyCollection.Enumerator

枚举 SortedDictionary<TKey,TValue>.KeyCollection 的元素。Enumerates the elements of a SortedDictionary<TKey,TValue>.KeyCollection.

SortedDictionary<TKey,TValue>.ValueCollection.Enumerator

枚举 SortedDictionary<TKey,TValue>.ValueCollection 的元素。Enumerates the elements of a SortedDictionary<TKey,TValue>.ValueCollection.

SortedSet<T>.Enumerator

枚举 SortedSet<T> 对象的元素。Enumerates the elements of a SortedSet<T> object.

Stack<T>.Enumerator

枚举 Stack<T> 的元素。Enumerates the elements of a Stack<T>.

接口

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.

ISet<T>

提供用于集的抽象的基接口。Provides the base interface for the abstraction of sets.

注解

许多泛型集合类型均为非泛型类型的直接模拟。Many of the generic collection types are direct analogs of nongeneric types. Dictionary<TKey,TValue>Hashtable 的泛型版本;它使用枚举的泛型结构 KeyValuePair<TKey,TValue> 而不是 DictionaryEntryDictionary<TKey,TValue> is a generic version of Hashtable; it uses the generic structure KeyValuePair<TKey,TValue> for enumeration instead of DictionaryEntry. List<T>ArrayList 的泛型版本。List<T> is a generic version of ArrayList. 存在响应非泛型版本的泛型 Queue<T>Stack<T> 类。There are generic Queue<T> and Stack<T> classes that correspond to the nongeneric versions. 存在 SortedList<TKey,TValue> 的泛型和非泛型版本。There are generic and nongeneric versions of SortedList<TKey,TValue>. 这两个版本均为字典和列表的混合。Both versions are hybrids of a dictionary and a list. SortedDictionary<TKey,TValue> 泛型类是一个纯字典,并且没有任何非泛型对应项。The SortedDictionary<TKey,TValue> generic class is a pure dictionary and has no nongeneric counterpart. LinkedList<T>泛型类是真正的链接的列表,并有任何非泛型对应项。The LinkedList<T> generic class is a true linked list and has no nongeneric counterpart.

另请参阅