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> 中尋找的索引鍵。

傳回

如果 key 位於 Lookup<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)

適用於