Lookup<TKey,TElement>.Contains(TKey) 方法

定义

确定指定的键是否位于 Lookup<TKey,TElement> 中。

public:
 virtual bool Contains(TKey key);
public bool Contains (TKey key);
abstract member Contains : 'Key -> bool
override this.Contains : 'Key -> bool
Public Function Contains (key As TKey) As Boolean

参数

key
TKey

要在 Lookup<TKey,TElement> 中查找的键。

返回

Boolean

如果 keyLookup<TKey,TElement> 中,则为 true;否则为 false

实现

示例

下面的示例演示如何用于 Contains 确定是否 Lookup<TKey,TElement> 包含指定的键。 此代码示例是为类提供的大型示例的 Lookup<TKey,TElement> 一部分。

// Determine if there is a key with the value 'G' in the Lookup.
bool hasG = lookup.Contains('G');
' Determine if there is a key with the value 'G' in the Lookup.
Dim hasG As Boolean = lookup.Contains("G"c)

适用于