Dictionary<TKey,TValue>.ValueCollection Dictionary<TKey,TValue>.ValueCollection Dictionary<TKey,TValue>.ValueCollection Dictionary<TKey,TValue>.ValueCollection Class

定義

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

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

類型參數

TKey
TValue
繼承
Dictionary<TKey,TValue>.ValueCollectionDictionary<TKey,TValue>.ValueCollectionDictionary<TKey,TValue>.ValueCollectionDictionary<TKey,TValue>.ValueCollection
屬性
實作

備註

Dictionary<TKey,TValue>.Values屬性會Dictionary<TKey,TValue>傳回這個類型的實例, 其中包含中的所有值。The Dictionary<TKey,TValue>.Values property returns an instance of this type, containing all the values in that Dictionary<TKey,TValue>. 雖然 Dictionary<TKey,TValue>.ValueCollection 中值的順序並未指定,但此順序會與 Dictionary<TKey,TValue>.KeyCollection 屬性傳回之 Dictionary<TKey,TValue>.Keys 中關聯索引鍵的順序相同。The order of the values in the Dictionary<TKey,TValue>.ValueCollection is unspecified, but it is the same order as the associated keys in the Dictionary<TKey,TValue>.KeyCollection returned by the Dictionary<TKey,TValue>.Keys property.

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

建構函式

Dictionary<TKey,TValue>.ValueCollection(Dictionary<TKey,TValue>) Dictionary<TKey,TValue>.ValueCollection(Dictionary<TKey,TValue>) Dictionary<TKey,TValue>.ValueCollection(Dictionary<TKey,TValue>) Dictionary<TKey,TValue>.ValueCollection(Dictionary<TKey,TValue>)

初始化 Dictionary<TKey,TValue>.ValueCollection 類別的新執行個體,反映指定 Dictionary<TKey,TValue> 中的值。Initializes a new instance of the Dictionary<TKey,TValue>.ValueCollection class that reflects the values in the specified Dictionary<TKey,TValue>.

屬性

Count Count Count Count

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

方法

CopyTo(TValue[], Int32) CopyTo(TValue[], Int32) CopyTo(TValue[], Int32) CopyTo(TValue[], Int32)

從指定的陣列索引處開始,複製 Dictionary<TKey,TValue>.ValueCollection 元素至現有一維 ArrayCopies the Dictionary<TKey,TValue>.ValueCollection 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()

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

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 索引開始,將 Array 的項目複製到 ArrayCopies 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<TValue>.Add(TValue) ICollection<TValue>.Add(TValue) ICollection<TValue>.Add(TValue) ICollection<TValue>.Add(TValue)

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

ICollection<TValue>.Clear() ICollection<TValue>.Clear() ICollection<TValue>.Clear() ICollection<TValue>.Clear()

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

ICollection<TValue>.Contains(TValue) ICollection<TValue>.Contains(TValue) ICollection<TValue>.Contains(TValue) ICollection<TValue>.Contains(TValue)

判斷 ICollection<T> 是否包含特定值。Determines whether the ICollection<T> contains a specific value.

ICollection<TValue>.IsReadOnly ICollection<TValue>.IsReadOnly ICollection<TValue>.IsReadOnly ICollection<TValue>.IsReadOnly

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

ICollection<TValue>.Remove(TValue) ICollection<TValue>.Remove(TValue) ICollection<TValue>.Remove(TValue) ICollection<TValue>.Remove(TValue)

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

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

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

IEnumerable<TValue>.GetEnumerator() IEnumerable<TValue>.GetEnumerator() IEnumerable<TValue>.GetEnumerator() IEnumerable<TValue>.GetEnumerator()

傳回逐一查看集合的列舉值。Returns an enumerator that iterates through a 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.

只要不修改集合,就可以同時支援多個讀取器。Dictionary<TKey,TValue>.ValueCollectionA Dictionary<TKey,TValue>.ValueCollection 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.