System.Collections.Generic 命名空间

包含定义泛型集合的接口和类,这些类允许用户创建强类型集合,这些集合提供比非泛型强类型集合更好的类型安全性和性能。

名称 说明
CollectionExtensions

为泛型集合提供扩展方法。

Comparer<T>

为泛型接口的 IComparer<T> 实现提供基类。

Dictionary<TKey,TValue>.KeyCollection

表示键的 Dictionary<TKey,TValue>集合。 此类不能被继承。

Dictionary<TKey,TValue>.ValueCollection

表示值集合。Dictionary<TKey,TValue> 此类不能被继承。

Dictionary<TKey,TValue>

表示键和值的集合。

EqualityComparer<T>

为泛型接口的 IEqualityComparer<T> 实现提供基类。

HashSet<T>

表示一组值。

KeyedByTypeCollection<TItem>

提供一个集合,其项是用作键的类型。

KeyNotFoundException

当为访问集合中的元素指定的键与集合中的任何键不匹配时引发的异常。

KeyValuePair

创建结构的实例 KeyValuePair<TKey,TValue>

LinkedList<T>

表示一个双重链接的列表。

LinkedListNode<T>

表示 . 中的 LinkedList<T>节点。 此类不能被继承。

List<T>

表示可由索引访问的强类型对象列表。 提供用于搜索、排序和操作列表的方法。

Queue<T>

表示对象的先入先出集合。

SortedDictionary<TKey,TValue>.KeyCollection

表示键的 SortedDictionary<TKey,TValue>集合。 此类不能被继承。

SortedDictionary<TKey,TValue>.ValueCollection

表示值集合。SortedDictionary<TKey,TValue> 此类不能被继承。

SortedDictionary<TKey,TValue>

表示键/值对的集合,这些键/值对在键上排序。

SortedList<TKey,TValue>

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

SortedSet<T>

表示按排序顺序维护的对象集合。

Stack<T>

表示同一指定类型的实例的上一出 (LIFO) 集合的可变大小。

SynchronizedCollection<T>

提供线程安全的集合,该集合包含泛型参数指定为元素的类型的对象。

SynchronizedKeyedCollection<K,T>

提供一个线程安全的集合,该集合包含泛型参数指定的类型的对象以及按键分组的对象。

SynchronizedReadOnlyCollection<T>

提供线程安全的只读集合,该集合包含泛型参数指定为元素的类型的对象。

结构

名称 说明
Dictionary<TKey,TValue>.Enumerator

枚举 . 的 Dictionary<TKey,TValue>元素

Dictionary<TKey,TValue>.KeyCollection.Enumerator

枚举 . 的 Dictionary<TKey,TValue>.KeyCollection元素

Dictionary<TKey,TValue>.ValueCollection.Enumerator

枚举 . 的 Dictionary<TKey,TValue>.ValueCollection元素

HashSet<T>.Enumerator

枚举对象的元素 HashSet<T>

KeyValuePair<TKey,TValue>

定义可以设置或检索的键/值对。

LinkedList<T>.Enumerator

枚举 . 的 LinkedList<T>元素

List<T>.Enumerator

枚举 . 的 List<T>元素

Queue<T>.Enumerator

枚举 . 的 Queue<T>元素

SortedDictionary<TKey,TValue>.Enumerator

枚举 . 的 SortedDictionary<TKey,TValue>元素

SortedDictionary<TKey,TValue>.KeyCollection.Enumerator

枚举 . 的 SortedDictionary<TKey,TValue>.KeyCollection元素

SortedDictionary<TKey,TValue>.ValueCollection.Enumerator

枚举 . 的 SortedDictionary<TKey,TValue>.ValueCollection元素

SortedSet<T>.Enumerator

枚举对象的元素 SortedSet<T>

Stack<T>.Enumerator

枚举 . 的 Stack<T>元素

接口

名称 说明
IAsyncEnumerable<T>

公开一个枚举器,该枚举器提供对指定类型的值的异步迭代。

IAsyncEnumerator<T>

支持对泛型集合进行简单的异步迭代。

ICollection<T>

定义用于操作泛型集合的方法。

IComparer<T>

定义类型实现以比较两个对象的方法。

IDictionary<TKey,TValue>

表示键/值对的泛型集合。

IEnumerable<T>

公开枚举器,该枚举器支持对指定类型的集合进行简单迭代。

IEnumerator<T>

支持对泛型集合进行简单迭代。

IEqualityComparer<T>

定义用于支持对象相等比较的方法。

IList<T>

表示可由索引单独访问的对象集合。

IReadOnlyCollection<T>

表示元素的强类型只读集合。

IReadOnlyDictionary<TKey,TValue>

表示键/值对的泛型只读集合。

IReadOnlyList<T>

表示可通过索引访问的元素的只读集合。

ISet<T>

为集的抽象提供基接口。

注解

许多泛型集合类型都是非泛型类型的直接模拟。 Dictionary<TKey,TValue>Hashtable的一个泛型版本;它使用KeyValuePair<TKey,TValue>这个泛型结构进行枚举,而不是使用DictionaryEntryList<T>ArrayList 的通用版本。 有一些泛型 Queue<T>Stack<T> 类对应于非泛型版本。 有泛型和非泛型版本的 SortedList<TKey,TValue>。 这两个版本都是字典和列表的混合版本。 SortedDictionary<TKey,TValue>泛型类是纯字典,没有非泛型对应项。 LinkedList<T>泛型类是一个真正的链接列表,没有非泛型对应项。

另请参阅