SortedDictionary<TKey,TValue>.KeyCollection SortedDictionary<TKey,TValue>.KeyCollection SortedDictionary<TKey,TValue>.KeyCollection SortedDictionary<TKey,TValue>.KeyCollection Class

定義

表示 SortedDictionary<TKey,TValue> 中的索引鍵集合。Represents the collection of keys in a SortedDictionary<TKey,TValue>. 這個類別無法被繼承。This class cannot be inherited.

public: ref class SortedDictionary<TKey, TValue>::KeyCollection sealed : System::Collections::Generic::ICollection<TKey>, System::Collections::Generic::IEnumerable<TKey>, System::Collections::Generic::IReadOnlyCollection<TKey>, System::Collections::ICollection
[System.Serializable]
public sealed class SortedDictionary<TKey,TValue>.KeyCollection : System.Collections.Generic.ICollection<TKey>, System.Collections.Generic.IEnumerable<TKey>, System.Collections.Generic.IReadOnlyCollection<TKey>, System.Collections.ICollection
type SortedDictionary<'Key, 'Value>.KeyCollection = class
    interface ICollection<'Key>
    interface ICollection
    interface IReadOnlyCollection<'Key>
    interface seq<'Key>
    interface IEnumerable
Public NotInheritable Class SortedDictionary(Of TKey, TValue).KeyCollection
Implements ICollection, ICollection(Of TKey), IEnumerable(Of TKey), IReadOnlyCollection(Of TKey)

類型參數

TKey
TValue
繼承
SortedDictionary<TKey,TValue>.KeyCollectionSortedDictionary<TKey,TValue>.KeyCollectionSortedDictionary<TKey,TValue>.KeyCollectionSortedDictionary<TKey,TValue>.KeyCollection
屬性
實作

備註

SortedDictionary<TKey,TValue>.Keys屬性會SortedDictionary<TKey,TValue>傳回這個類型的實例, 其中包含中的所有索引鍵。The SortedDictionary<TKey,TValue>.Keys property returns an instance of this type, containing all the keys in that SortedDictionary<TKey,TValue>. SortedDictionary<TKey,TValue>.KeyCollection的索引鍵順序與SortedDictionary<TKey,TValue>中的專案順序相同, 這與SortedDictionary<TKey,TValue>.Values屬性SortedDictionary<TKey,TValue>.ValueCollection傳回之中關聯值的順序相同。The order of the keys in the SortedDictionary<TKey,TValue>.KeyCollection is the same as the order of elements in the SortedDictionary<TKey,TValue>, the same as the order of the associated values in the SortedDictionary<TKey,TValue>.ValueCollection returned by the SortedDictionary<TKey,TValue>.Values property.

不是靜態複本SortedDictionary<TKey,TValue>.KeyCollection , 而是指回原始SortedDictionary<TKey,TValue>中的索引鍵。 SortedDictionary<TKey,TValue>.KeyCollectionThe SortedDictionary<TKey,TValue>.KeyCollection is not a static copy; instead, the SortedDictionary<TKey,TValue>.KeyCollection refers back to the keys in the original SortedDictionary<TKey,TValue>. 因此, 的SortedDictionary<TKey,TValue>變更會繼續反映SortedDictionary<TKey,TValue>.KeyCollection在中。Therefore, changes to the SortedDictionary<TKey,TValue> continue to be reflected in the SortedDictionary<TKey,TValue>.KeyCollection.

建構函式

SortedDictionary<TKey,TValue>.KeyCollection(SortedDictionary<TKey,TValue>) SortedDictionary<TKey,TValue>.KeyCollection(SortedDictionary<TKey,TValue>) SortedDictionary<TKey,TValue>.KeyCollection(SortedDictionary<TKey,TValue>) SortedDictionary<TKey,TValue>.KeyCollection(SortedDictionary<TKey,TValue>)

初始化 SortedDictionary<TKey,TValue>.KeyCollection 類別的新執行個體,反映指定 SortedDictionary<TKey,TValue> 中的索引鍵。Initializes a new instance of the SortedDictionary<TKey,TValue>.KeyCollection class that reflects the keys in the specified SortedDictionary<TKey,TValue>.

屬性

Count Count Count Count

取得 SortedDictionary<TKey,TValue>.KeyCollection 中所包含的項目數。Gets the number of elements contained in the SortedDictionary<TKey,TValue>.KeyCollection.

方法

CopyTo(TKey[], Int32) CopyTo(TKey[], Int32) CopyTo(TKey[], Int32) CopyTo(TKey[], Int32)

從指定的陣列索引處開始,複製 SortedDictionary<TKey,TValue>.KeyCollection 項目至現有一維陣列。Copies the SortedDictionary<TKey,TValue>.KeyCollection elements to an existing one-dimensional array, starting at the specified array index.

Equals(Object) Equals(Object) Equals(Object) Equals(Object)

判斷指定的物件是否等於目前的物件。Determines whether the specified object is equal to the current object.

(Inherited from Object)
GetEnumerator() GetEnumerator() GetEnumerator() GetEnumerator()

傳回在 SortedDictionary<TKey,TValue>.KeyCollection 中逐一查看的列舉值。Returns an enumerator that iterates through the SortedDictionary<TKey,TValue>.KeyCollection.

GetHashCode() GetHashCode() GetHashCode() GetHashCode()

做為預設雜湊函式。Serves as the default hash function.

(Inherited from Object)
GetType() GetType() GetType() GetType()

取得目前執行個體的 TypeGets the Type of the current instance.

(Inherited from Object)
MemberwiseClone() MemberwiseClone() MemberwiseClone() MemberwiseClone()

建立目前 Object 的淺層複本 (Shallow Copy)。Creates a shallow copy of the current Object.

(Inherited from Object)
ToString() ToString() ToString() ToString()

傳回代表目前物件的字串。Returns a string that represents the current object.

(Inherited from Object)

明確介面實作

ICollection.CopyTo(Array, Int32) ICollection.CopyTo(Array, Int32) ICollection.CopyTo(Array, Int32) ICollection.CopyTo(Array, Int32)

從特定的陣列索引開始,將 ICollection 的項目複製到陣列中。Copies the elements of the ICollection to an array, starting at a particular array index.

ICollection.IsSynchronized ICollection.IsSynchronized ICollection.IsSynchronized ICollection.IsSynchronized

取得值,這個值表示對 ICollection 的存取是否同步 (安全執行緒)。Gets a value indicating whether access to the ICollection is synchronized (thread safe).

ICollection.SyncRoot ICollection.SyncRoot ICollection.SyncRoot ICollection.SyncRoot

取得可用以同步存取 ICollection 的物件。Gets an object that can be used to synchronize access to the ICollection.

ICollection<TKey>.Add(TKey) ICollection<TKey>.Add(TKey) ICollection<TKey>.Add(TKey) ICollection<TKey>.Add(TKey)

將項目加入至 ICollection<T>Adds an item to the ICollection<T>. 這個實作一律會擲回 NotSupportedExceptionThis implementation always throws a NotSupportedException.

ICollection<TKey>.Clear() ICollection<TKey>.Clear() ICollection<TKey>.Clear() ICollection<TKey>.Clear()

ICollection<T> 中移除所有項目。Removes all items from the ICollection<T>. 這個實作一律會擲回 NotSupportedExceptionThis implementation always throws a NotSupportedException.

ICollection<TKey>.Contains(TKey) ICollection<TKey>.Contains(TKey) ICollection<TKey>.Contains(TKey) ICollection<TKey>.Contains(TKey)

判斷 ICollection<T> 是否包含指定的值。Determines whether the ICollection<T> contains the specified value.

ICollection<TKey>.IsReadOnly ICollection<TKey>.IsReadOnly ICollection<TKey>.IsReadOnly ICollection<TKey>.IsReadOnly

取得值,指出 ICollection<T> 是否唯讀。Gets a value indicating whether the ICollection<T> is read-only.

ICollection<TKey>.Remove(TKey) ICollection<TKey>.Remove(TKey) ICollection<TKey>.Remove(TKey) ICollection<TKey>.Remove(TKey)

ICollection<T> 移除特定物件之第一個符合的元素。Removes the first occurrence of a specific object from the ICollection<T>. 這個實作一律會擲回 NotSupportedExceptionThis implementation always throws a NotSupportedException.

IEnumerable.GetEnumerator() IEnumerable.GetEnumerator() IEnumerable.GetEnumerator() IEnumerable.GetEnumerator()

傳回逐一查看集合的列舉值。Returns an enumerator that iterates through the collection.

IEnumerable<TKey>.GetEnumerator() IEnumerable<TKey>.GetEnumerator() IEnumerable<TKey>.GetEnumerator() IEnumerable<TKey>.GetEnumerator()

傳回逐一查看集合的列舉值。Returns an enumerator that iterates through the collection.

擴充方法

CopyToDataTable<T>(IEnumerable<T>) CopyToDataTable<T>(IEnumerable<T>) CopyToDataTable<T>(IEnumerable<T>) CopyToDataTable<T>(IEnumerable<T>)

根據輸入 DataTable 物件 (其中泛型參數 TDataRow) 傳回包含 IEnumerable<T> 物件複本的 DataRowReturns a DataTable that contains copies of the DataRow objects, given an input IEnumerable<T> object where the generic parameter T is DataRow.

CopyToDataTable<T>(IEnumerable<T>, DataTable, LoadOption) CopyToDataTable<T>(IEnumerable<T>, DataTable, LoadOption) CopyToDataTable<T>(IEnumerable<T>, DataTable, LoadOption) CopyToDataTable<T>(IEnumerable<T>, DataTable, LoadOption)

根據輸入 DataRow 物件 (其中泛型參數 TDataTable),將 IEnumerable<T> 物件複製到指定的 DataRowCopies DataRow objects to the specified DataTable, given an input IEnumerable<T> object where the generic parameter T is DataRow.

CopyToDataTable<T>(IEnumerable<T>, DataTable, LoadOption, FillErrorEventHandler) CopyToDataTable<T>(IEnumerable<T>, DataTable, LoadOption, FillErrorEventHandler) CopyToDataTable<T>(IEnumerable<T>, DataTable, LoadOption, FillErrorEventHandler) CopyToDataTable<T>(IEnumerable<T>, DataTable, LoadOption, FillErrorEventHandler)

根據輸入 DataRow 物件 (其中泛型參數 TDataTable),將 IEnumerable<T> 物件複製到指定的 DataRowCopies DataRow objects to the specified DataTable, given an input IEnumerable<T> object where the generic parameter T is DataRow.

Cast<TResult>(IEnumerable) Cast<TResult>(IEnumerable) Cast<TResult>(IEnumerable) Cast<TResult>(IEnumerable)

IEnumerable 的項目轉換成指定的型別。Casts the elements of an IEnumerable to the specified type.

OfType<TResult>(IEnumerable) OfType<TResult>(IEnumerable) OfType<TResult>(IEnumerable) OfType<TResult>(IEnumerable)

根據指定的型別來篩選 IEnumerable 的項目。Filters the elements of an IEnumerable based on a specified type.

AsParallel(IEnumerable) AsParallel(IEnumerable) AsParallel(IEnumerable) AsParallel(IEnumerable)

啟用查詢的平行化作業。Enables parallelization of a query.

AsQueryable(IEnumerable) AsQueryable(IEnumerable) AsQueryable(IEnumerable) AsQueryable(IEnumerable)

IEnumerable 轉換成 IQueryableConverts an IEnumerable to an IQueryable.

Ancestors<T>(IEnumerable<T>) Ancestors<T>(IEnumerable<T>) Ancestors<T>(IEnumerable<T>) Ancestors<T>(IEnumerable<T>)

傳回包含來源集合中每個節點祖系的項目集合。Returns a collection of elements that contains the ancestors of every node in the source collection.

Ancestors<T>(IEnumerable<T>, XName) Ancestors<T>(IEnumerable<T>, XName) Ancestors<T>(IEnumerable<T>, XName) Ancestors<T>(IEnumerable<T>, XName)

傳回包含來源集合中每個節點祖系的已篩選項目集合。Returns a filtered collection of elements that contains the ancestors of every node in the source collection. 集合中只會包含具有相符之 XName 的項目。Only elements that have a matching XName are included in the collection.

DescendantNodes<T>(IEnumerable<T>) DescendantNodes<T>(IEnumerable<T>) DescendantNodes<T>(IEnumerable<T>) DescendantNodes<T>(IEnumerable<T>)

傳回來源集合中每個文件和項目之子代節點的集合。Returns a collection of the descendant nodes of every document and element in the source collection.

Descendants<T>(IEnumerable<T>) Descendants<T>(IEnumerable<T>) Descendants<T>(IEnumerable<T>) Descendants<T>(IEnumerable<T>)

傳回包含來源集合中每個項目和文件之子代項目的項目集合。Returns a collection of elements that contains the descendant elements of every element and document in the source collection.

Descendants<T>(IEnumerable<T>, XName) Descendants<T>(IEnumerable<T>, XName) Descendants<T>(IEnumerable<T>, XName) Descendants<T>(IEnumerable<T>, XName)

傳回已篩選的項目集合,其中包含來源集合中每個項目和文件的子代項目。Returns a filtered collection of elements that contains the descendant elements of every element and document in the source collection. 集合中只會包含具有相符之 XName 的項目。Only elements that have a matching XName are included in the collection.

Elements<T>(IEnumerable<T>) Elements<T>(IEnumerable<T>) Elements<T>(IEnumerable<T>) Elements<T>(IEnumerable<T>)

傳回來源集合中每個項目和文件的子項目集合。Returns a collection of the child elements of every element and document in the source collection.

Elements<T>(IEnumerable<T>, XName) Elements<T>(IEnumerable<T>, XName) Elements<T>(IEnumerable<T>, XName) Elements<T>(IEnumerable<T>, XName)

傳回來源集合中每個項目和文件的已篩選子項目集合。Returns a filtered collection of the child elements of every element and document in the source collection. 集合中只會包含具有相符之 XName 的項目。Only elements that have a matching XName are included in the collection.

InDocumentOrder<T>(IEnumerable<T>) InDocumentOrder<T>(IEnumerable<T>) InDocumentOrder<T>(IEnumerable<T>) InDocumentOrder<T>(IEnumerable<T>)

傳回包含來源集合中所有節點的節點集合,依據文件順序來排序。Returns a collection of nodes that contains all nodes in the source collection, sorted in document order.

Nodes<T>(IEnumerable<T>) Nodes<T>(IEnumerable<T>) Nodes<T>(IEnumerable<T>) Nodes<T>(IEnumerable<T>)

傳回來源集合中每個文件和項目的子節點集合。Returns a collection of the child nodes of every document and element in the source collection.

Remove<T>(IEnumerable<T>) Remove<T>(IEnumerable<T>) Remove<T>(IEnumerable<T>) Remove<T>(IEnumerable<T>)

在來源集合中,從每一個節點的父節點移除這些節點。Removes every node in the source collection from its parent node.

適用於

執行緒安全性

此類型的Shared公用靜態 (在 Visual Basic 中) 成員是安全線程。Public static (Shared in Visual Basic) members of this type are thread safe. 不保證任何執行個體成員是安全執行緒。Any instance members are not guaranteed to be thread safe.

只要不修改集合,就可以同時支援多個讀取器。SortedDictionary<TKey,TValue>.KeyCollectionA SortedDictionary<TKey,TValue>.KeyCollection can support multiple readers concurrently, as long as the collection is not modified. 儘管如此, 透過集合列舉, 本質上並不是安全線程的程式。Even so, enumerating through a collection is intrinsically not a thread-safe procedure. 若要確保列舉期間的執行緒安全性,您可以在整個列舉期間鎖定集合。To guarantee thread safety during enumeration, you can lock the collection during the entire enumeration. 若要讓多重執行緒能夠存取集合以便進行讀取和寫入,您必須實作自己的同步處理。To allow the collection to be accessed by multiple threads for reading and writing, you must implement your own synchronization.