ReadOnlyDictionary<TKey,TValue> ReadOnlyDictionary<TKey,TValue> ReadOnlyDictionary<TKey,TValue> ReadOnlyDictionary<TKey,TValue> Class

定義

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

generic <typename TKey, typename TValue>
public ref class ReadOnlyDictionary : System::Collections::Generic::ICollection<System::Collections::Generic::KeyValuePair<TKey, TValue>>, System::Collections::Generic::IDictionary<TKey, TValue>, System::Collections::Generic::IEnumerable<System::Collections::Generic::KeyValuePair<TKey, TValue>>, System::Collections::Generic::IReadOnlyCollection<System::Collections::Generic::KeyValuePair<TKey, TValue>>, System::Collections::Generic::IReadOnlyDictionary<TKey, TValue>, System::Collections::IDictionary
[System.Serializable]
public class ReadOnlyDictionary<TKey,TValue> : System.Collections.Generic.ICollection<System.Collections.Generic.KeyValuePair<TKey,TValue>>, System.Collections.Generic.IDictionary<TKey,TValue>, System.Collections.Generic.IEnumerable<System.Collections.Generic.KeyValuePair<TKey,TValue>>, System.Collections.Generic.IReadOnlyCollection<System.Collections.Generic.KeyValuePair<TKey,TValue>>, System.Collections.Generic.IReadOnlyDictionary<TKey,TValue>, System.Collections.IDictionary
type ReadOnlyDictionary<'Key, 'Value> = class
    interface IDictionary<'Key, 'Value>
    interface IDictionary
    interface IReadOnlyDictionary<'Key, 'Value>
    interface ICollection<KeyValuePair<'Key, 'Value>>
    interface seq<KeyValuePair<'Key, 'Value>>
    interface IEnumerable
    interface ICollection
    interface IReadOnlyCollection<KeyValuePair<'Key, 'Value>>
Public Class ReadOnlyDictionary(Of TKey, TValue)
Implements ICollection(Of KeyValuePair(Of TKey, TValue)), IDictionary, IDictionary(Of TKey, TValue), IEnumerable(Of KeyValuePair(Of TKey, TValue)), IReadOnlyCollection(Of KeyValuePair(Of TKey, TValue)), IReadOnlyDictionary(Of TKey, TValue)

類型參數

TKey

字典中之索引鍵的類型。The type of keys in the dictionary.

TValue

字典中之值的類型。The type of values in the dictionary.

繼承
ReadOnlyDictionary<TKey,TValue>ReadOnlyDictionary<TKey,TValue>ReadOnlyDictionary<TKey,TValue>ReadOnlyDictionary<TKey,TValue>
屬性
實作

建構函式

ReadOnlyDictionary<TKey,TValue>(IDictionary<TKey,TValue>) ReadOnlyDictionary<TKey,TValue>(IDictionary<TKey,TValue>) ReadOnlyDictionary<TKey,TValue>(IDictionary<TKey,TValue>) ReadOnlyDictionary<TKey,TValue>(IDictionary<TKey,TValue>)

初始化 ReadOnlyDictionary<TKey,TValue> 類別的新執行個體,這個執行個體是指定之字典的包裝函式。Initializes a new instance of the ReadOnlyDictionary<TKey,TValue> class that is a wrapper around the specified dictionary.

屬性

Count Count Count Count

取得字典中的項目數目。Gets the number of items in the dictionary.

Dictionary Dictionary Dictionary Dictionary

取得這個 ReadOnlyDictionary<TKey,TValue> 物件包裝的字典。Gets the dictionary that is wrapped by this ReadOnlyDictionary<TKey,TValue> object.

Item[TKey] Item[TKey] Item[TKey] Item[TKey]

取得具有指定之索引鍵的項目。Gets the element that has the specified key.

Keys Keys Keys Keys

取得索引鍵集合,其中包含此字典的索引鍵。Gets a key collection that contains the keys of the dictionary.

Values Values Values Values

取得集合,其中包含字典中的所有值。Gets a collection that contains the values in the dictionary.

方法

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

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

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()

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

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)
TryGetValue(TKey, TValue) TryGetValue(TKey, TValue) TryGetValue(TKey, TValue) TryGetValue(TKey, TValue)

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

明確介面實作

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

從指定的陣列索引處開始,將字典的項目複製到陣列。Copies the elements of the dictionary to an array, starting at the specified array index.

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

取得值,這個值指出是否同步存取字典 (具備執行緒安全)。Gets a value that indicates whether access to the dictionary is synchronized (thread safe).

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

取得物件,該物件可用來同步存取字典。Gets an object that can be used to synchronize access to the dictionary.

ICollection<KeyValuePair<TKey,TValue>>.Add(KeyValuePair<TKey,TValue>) ICollection<KeyValuePair<TKey,TValue>>.Add(KeyValuePair<TKey,TValue>) ICollection<KeyValuePair<TKey,TValue>>.Add(KeyValuePair<TKey,TValue>) ICollection<KeyValuePair<TKey,TValue>>.Add(KeyValuePair<TKey,TValue>)

在所有情況下都會擲回 NotSupportedException 例外狀況。Throws a NotSupportedException exception in all cases.

ICollection<KeyValuePair<TKey,TValue>>.Clear() ICollection<KeyValuePair<TKey,TValue>>.Clear() ICollection<KeyValuePair<TKey,TValue>>.Clear() ICollection<KeyValuePair<TKey,TValue>>.Clear()

在所有情況下都會擲回 NotSupportedException 例外狀況。Throws a NotSupportedException exception in all cases.

ICollection<KeyValuePair<TKey,TValue>>.Contains(KeyValuePair<TKey,TValue>) ICollection<KeyValuePair<TKey,TValue>>.Contains(KeyValuePair<TKey,TValue>) ICollection<KeyValuePair<TKey,TValue>>.Contains(KeyValuePair<TKey,TValue>) ICollection<KeyValuePair<TKey,TValue>>.Contains(KeyValuePair<TKey,TValue>)

判斷字典是否包含特定值。Determines whether the dictionary contains a specific value.

ICollection<KeyValuePair<TKey,TValue>>.CopyTo(KeyValuePair<TKey,TValue>[], Int32) ICollection<KeyValuePair<TKey,TValue>>.CopyTo(KeyValuePair<TKey,TValue>[], Int32) ICollection<KeyValuePair<TKey,TValue>>.CopyTo(KeyValuePair<TKey,TValue>[], Int32) ICollection<KeyValuePair<TKey,TValue>>.CopyTo(KeyValuePair<TKey,TValue>[], Int32)

從指定的陣列索引處開始,將字典的項目複製到陣列。Copies the elements of the dictionary to an array, starting at the specified array index.

ICollection<KeyValuePair<TKey,TValue>>.IsReadOnly ICollection<KeyValuePair<TKey,TValue>>.IsReadOnly ICollection<KeyValuePair<TKey,TValue>>.IsReadOnly ICollection<KeyValuePair<TKey,TValue>>.IsReadOnly

取得值,這個值表示字典是否為唯讀。Gets a value that indicates whether the dictionary is read-only.

ICollection<KeyValuePair<TKey,TValue>>.Remove(KeyValuePair<TKey,TValue>) ICollection<KeyValuePair<TKey,TValue>>.Remove(KeyValuePair<TKey,TValue>) ICollection<KeyValuePair<TKey,TValue>>.Remove(KeyValuePair<TKey,TValue>) ICollection<KeyValuePair<TKey,TValue>>.Remove(KeyValuePair<TKey,TValue>)

在所有情況下都會擲回 NotSupportedException 例外狀況。Throws a NotSupportedException exception in all cases.

IDictionary.Add(Object, Object) IDictionary.Add(Object, Object) IDictionary.Add(Object, Object) IDictionary.Add(Object, Object)

在所有情況下都會擲回 NotSupportedException 例外狀況。Throws a NotSupportedException exception in all cases.

IDictionary.Clear() IDictionary.Clear() IDictionary.Clear() IDictionary.Clear()

在所有情況下都會擲回 NotSupportedException 例外狀況。Throws a NotSupportedException exception in all cases.

IDictionary.Contains(Object) IDictionary.Contains(Object) IDictionary.Contains(Object) IDictionary.Contains(Object)

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

IDictionary.GetEnumerator() IDictionary.GetEnumerator() IDictionary.GetEnumerator() IDictionary.GetEnumerator()

傳回字典的列舉值。Returns an enumerator for the dictionary.

IDictionary.IsFixedSize IDictionary.IsFixedSize IDictionary.IsFixedSize IDictionary.IsFixedSize

取得值,這個值表示字典是否具有固定大小。Gets a value that indicates whether the dictionary has a fixed size.

IDictionary.IsReadOnly IDictionary.IsReadOnly IDictionary.IsReadOnly IDictionary.IsReadOnly

取得值,這個值表示字典是否為唯讀。Gets a value that indicates whether the dictionary is read-only.

IDictionary.Item[Object] IDictionary.Item[Object] IDictionary.Item[Object] IDictionary.Item[Object]

取得具有指定之索引鍵的項目。Gets the element that has the specified key.

IDictionary.Keys IDictionary.Keys IDictionary.Keys IDictionary.Keys

取得集合,其中包含字典的索引鍵。Gets a collection that contains the keys of the dictionary.

IDictionary.Remove(Object) IDictionary.Remove(Object) IDictionary.Remove(Object) IDictionary.Remove(Object)

在所有情況下都會擲回 NotSupportedException 例外狀況。Throws a NotSupportedException exception in all cases.

IDictionary.Values IDictionary.Values IDictionary.Values IDictionary.Values

取得集合,其中包含字典中的所有值。Gets a collection that contains the values in the dictionary.

IDictionary<TKey,TValue>.Add(TKey, TValue) IDictionary<TKey,TValue>.Add(TKey, TValue) IDictionary<TKey,TValue>.Add(TKey, TValue) IDictionary<TKey,TValue>.Add(TKey, TValue)

在所有情況下都會擲回 NotSupportedException 例外狀況。Throws a NotSupportedException exception in all cases.

IDictionary<TKey,TValue>.Item[TKey] IDictionary<TKey,TValue>.Item[TKey] IDictionary<TKey,TValue>.Item[TKey] IDictionary<TKey,TValue>.Item[TKey]

取得具有指定之索引鍵的項目。Gets the element that has the specified key.

IDictionary<TKey,TValue>.Keys IDictionary<TKey,TValue>.Keys IDictionary<TKey,TValue>.Keys IDictionary<TKey,TValue>.Keys

取得集合,其中包含字典的索引鍵。Gets a collection that contains the keys of the dictionary.

IDictionary<TKey,TValue>.Remove(TKey) IDictionary<TKey,TValue>.Remove(TKey) IDictionary<TKey,TValue>.Remove(TKey) IDictionary<TKey,TValue>.Remove(TKey)

在所有情況下都會擲回 NotSupportedException 例外狀況。Throws a NotSupportedException exception in all cases.

IDictionary<TKey,TValue>.Values IDictionary<TKey,TValue>.Values IDictionary<TKey,TValue>.Values IDictionary<TKey,TValue>.Values

取得集合,其中包含字典中的所有值。Gets a collection that contains the values in the dictionary.

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

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

IReadOnlyDictionary<TKey,TValue>.Keys IReadOnlyDictionary<TKey,TValue>.Keys IReadOnlyDictionary<TKey,TValue>.Keys IReadOnlyDictionary<TKey,TValue>.Keys

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

IReadOnlyDictionary<TKey,TValue>.Values IReadOnlyDictionary<TKey,TValue>.Values IReadOnlyDictionary<TKey,TValue>.Values IReadOnlyDictionary<TKey,TValue>.Values

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

擴充方法

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)
Remove<TKey,TValue>(IDictionary<TKey,TValue>, TKey, TValue) Remove<TKey,TValue>(IDictionary<TKey,TValue>, TKey, TValue) Remove<TKey,TValue>(IDictionary<TKey,TValue>, TKey, TValue) Remove<TKey,TValue>(IDictionary<TKey,TValue>, TKey, TValue)
TryAdd<TKey,TValue>(IDictionary<TKey,TValue>, TKey, TValue) TryAdd<TKey,TValue>(IDictionary<TKey,TValue>, TKey, TValue) TryAdd<TKey,TValue>(IDictionary<TKey,TValue>, TKey, TValue) TryAdd<TKey,TValue>(IDictionary<TKey,TValue>, TKey, TValue)
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.

適用於