IReadOnlyDictionary<TKey,TValue>.Item[TKey] 屬性

定義

取得在唯讀字典中擁有指定索引鍵的項目。

public:
 property TValue default[TKey] { TValue get(TKey key); };
public TValue this[TKey key] { get; }
member this.Item('Key) : 'Value
Default Public ReadOnly Property Item(key As TKey) As TValue

參數

key
TKey

要尋找的索引鍵。

屬性值

TValue

在唯讀字典中擁有指定索引鍵的項目。

例外狀況

keynull

屬性已擷取,並且找不到 key

備註

此屬性可讓您使用下列語法存取集合中的特定元素: myCollection[key] Visual Basic) 中的 (myCollection(key)

實作可能會因判斷物件的相等方式而有所不同:例如,實 IReadOnlyDictionary<TKey,TValue> 作的 類別可能會使用 Comparer<T>.Default 屬性,或者它可能會實作 IComparer<T> 方法。

實作可能會因是否允許 keynull而有所不同。

適用於