IReadOnlyDictionary<TKey,TValue>.ContainsKey(TKey) IReadOnlyDictionary<TKey,TValue>.ContainsKey(TKey) IReadOnlyDictionary<TKey,TValue>.ContainsKey(TKey) IReadOnlyDictionary<TKey,TValue>.ContainsKey(TKey) Method

定义

确定只读字典是否包含具有指定键的元素。Determines whether the read-only dictionary contains an element that has the specified key.

public:
 bool ContainsKey(TKey key);
public bool ContainsKey (TKey key);
abstract member ContainsKey : 'Key -> bool
Public Function ContainsKey (key As TKey) As Boolean

参数

key
TKey TKey TKey TKey

要定位的键。The key to locate.

返回

如果该只读词典包含一具有指定键的元素,则为 true;否则为 falsetrue if the read-only dictionary contains an element that has the specified key; otherwise, false.

异常

注解

各个实现确定对象的相等性的方式可能会有所不同;例如,实现 IReadOnlyDictionary<TKey,TValue> 的类可能使用 Comparer<T>.Default 属性,也可能实现 IComparer<T> 方法。Implementations can vary in how they determine the equality of objects; for example, the class that implements IReadOnlyDictionary<TKey,TValue> might use the Comparer<T>.Default property, or it might implement the IComparer<T> method.

实现在是否允许key null时可能有所不同。Implementations can vary in whether they allow key to be null.

适用于