IReadOnlyDictionary<TKey,TValue> IReadOnlyDictionary<TKey,TValue> IReadOnlyDictionary<TKey,TValue> IReadOnlyDictionary<TKey,TValue> Interface

定義

表示索引鍵/值組的唯讀集合。Represents a generic read-only collection of key/value pairs.

generic <typename TKey, typename TValue>
public interface class IReadOnlyDictionary : System::Collections::Generic::IEnumerable<System::Collections::Generic::KeyValuePair<TKey, TValue>>, System::Collections::Generic::IReadOnlyCollection<System::Collections::Generic::KeyValuePair<TKey, TValue>>
public interface IReadOnlyDictionary<TKey,TValue> : System.Collections.Generic.IEnumerable<System.Collections.Generic.KeyValuePair<TKey,TValue>>, System.Collections.Generic.IReadOnlyCollection<System.Collections.Generic.KeyValuePair<TKey,TValue>>
type IReadOnlyDictionary<'Key, 'Value> = interface
    interface IReadOnlyCollection<KeyValuePair<'Key, 'Value>>
    interface seq<KeyValuePair<'Key, 'Value>>
    interface IEnumerable
Public Interface IReadOnlyDictionary(Of TKey, TValue)
Implements IEnumerable(Of KeyValuePair(Of TKey, TValue)), IReadOnlyCollection(Of KeyValuePair(Of TKey, TValue))

類型參數

TKey

唯讀字典中的索引鍵類型。The type of keys in the read-only dictionary.

TValue

唯讀字典中值的型別。The type of values in the read-only dictionary.

衍生
實作

備註

每個項目是儲存在索引鍵/值組KeyValuePair<TKey,TValue>物件。Each element is a key/value pair that is stored in a KeyValuePair<TKey,TValue> object.

每一組必須有唯一的索引鍵。Each pair must have a unique key. 實作有所不同它們是否可讓您指定的索引鍵nullImplementations can vary in whether they allow you to specify a key that is null. 此值可以是null並不需要是唯一的。The value can be null and does not have to be unique. IReadOnlyDictionary<TKey,TValue>介面可讓所包含的金鑰和要列舉的值,但它並不代表任何特定的排序次序。The IReadOnlyDictionary<TKey,TValue> interface allows the contained keys and values to be enumerated, but it does not imply any particular sort order.

foreach陳述式的C#語言 (For Each在 Visual Basicfor each中C++) 需要的集合中的每個項目類型。The foreach statement of the C# language (For Each in Visual Basic, for each in C++) requires the type of each element in the collection. 因為每個項目的IReadOnlyDictionary<TKey,TValue>介面的索引鍵/值組,項目型別不是索引鍵的類型或值的類型。Because each element of the IReadOnlyDictionary<TKey,TValue> interface is a key/value pair, the element type is not the type of the key or the type of the value. 相反地,項目型別是KeyValuePair<TKey,TValue>,如下列範例所示。Instead, the element type is KeyValuePair<TKey,TValue>, as the following example illustrates.

for each(KeyValuePair<int, String^> kvp in myDictionary)
{
    Console::WriteLine("Key = {0}, Value = {1}", kvp.Key, kvp.Value);
}
foreach (KeyValuePair<int, string> kvp in myDictionary)
{
    Console.WriteLine("Key = {0}, Value = {1}", kvp.Key, kvp.Value);
}
For Each kvp As KeyValuePair(Of Integer, String) In myDictionary
    Console.WriteLine("Key = {0}, Value = {1}", kvp.Key, kvp.Value)
Next kvp

foreach陳述式會列舉值周圍的包裝函式; 它可讓只讀取集合中,不寫入至集合。The foreach statement is a wrapper around the enumerator; it allows only reading from the collection, not writing to the collection.

屬性

Count Count Count Count

取得集合中的項目數。Gets the number of elements in the collection.

(Inherited from IReadOnlyCollection<T>)
Item[TKey] Item[TKey] Item[TKey] Item[TKey]

取得在唯讀字典中擁有指定索引鍵的項目。Gets the element that has the specified key in the read-only dictionary.

Keys Keys Keys Keys

取得可列舉集合,其中包含唯讀字典中的索引鍵。Gets an enumerable collection that contains the keys in the read-only dictionary.

Values Values Values Values

取得可列舉集合,其中包含唯讀字典中的值。Gets an enumerable collection that contains the values in the read-only dictionary.

方法

ContainsKey(TKey) ContainsKey(TKey) ContainsKey(TKey) ContainsKey(TKey)

判斷唯讀字典是否包含具有指定索引鍵的項目。Determines whether the read-only dictionary contains an element that has the specified key.

GetEnumerator() GetEnumerator() GetEnumerator() GetEnumerator()

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

(Inherited from IEnumerable)
TryGetValue(TKey, TValue) TryGetValue(TKey, TValue) TryGetValue(TKey, TValue) TryGetValue(TKey, TValue)

取得與指定之索引鍵相關聯的值。Gets the value that is associated with the specified key.

Extension Methods

GetValueOrDefault<TKey,TValue>(IReadOnlyDictionary<TKey,TValue>, TKey) GetValueOrDefault<TKey,TValue>(IReadOnlyDictionary<TKey,TValue>, TKey) GetValueOrDefault<TKey,TValue>(IReadOnlyDictionary<TKey,TValue>, TKey) GetValueOrDefault<TKey,TValue>(IReadOnlyDictionary<TKey,TValue>, TKey)
GetValueOrDefault<TKey,TValue>(IReadOnlyDictionary<TKey,TValue>, TKey, TValue) GetValueOrDefault<TKey,TValue>(IReadOnlyDictionary<TKey,TValue>, TKey, TValue) GetValueOrDefault<TKey,TValue>(IReadOnlyDictionary<TKey,TValue>, TKey, TValue) GetValueOrDefault<TKey,TValue>(IReadOnlyDictionary<TKey,TValue>, TKey, TValue)
CopyToDataTable<T>(IEnumerable<T>) CopyToDataTable<T>(IEnumerable<T>) CopyToDataTable<T>(IEnumerable<T>) CopyToDataTable<T>(IEnumerable<T>)

傳回DataTable,其中包含副本DataRow物件,指定輸入IEnumerable<T>物件其中泛型參數TDataRowReturns 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至指定的物件DataTable,根據輸入IEnumerable<T>物件其中泛型參數TDataRowCopies 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至指定的物件DataTable,根據輸入IEnumerable<T>物件其中泛型參數TDataRowCopies 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)

將轉換IEnumerableIQueryableConverts 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.

適用於