System.Collections.Generic Namespace

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>

提供基底類別 (Base Class) 用於 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>

提供基底類別 (Base Class) 用於 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>

表示雙向連結串列 (Doubly-Linked List)。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>

表示物件的先進先出 (FIFO) 集合。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>
IAsyncEnumerator<T>
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> (而不是 DictionaryEntry) 來進行列舉。Dictionary<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.