Dictionary<TKey,TValue>.KeyCollection.ICollection<TKey>.Contains 方法

定義

判斷 ICollection<T> 是否包含特定值。

 virtual bool System.Collections.Generic.ICollection<TKey>.Contains(TKey item) = System::Collections::Generic::ICollection<TKey>::Contains;
bool ICollection<TKey>.Contains (TKey item);
abstract member System.Collections.Generic.ICollection<TKey>.Contains : 'Key -> bool
override this.System.Collections.Generic.ICollection<TKey>.Contains : 'Key -> bool
Function Contains (item As TKey) As Boolean Implements ICollection(Of TKey).Contains

參數

item
TKey

要在 ICollection<T> 中尋找的物件。

傳回

如果在 true 中找到 item,則為 ICollection<T>,否則為 false

實作

備註

實作依判斷物件相等的方法會有所不同;例如,List<T> 使用 Default,而 Dictionary<TKey,TValue> 則讓使用者指定要用來比較索引鍵的 IComparer<T> 實作。

這個方法是 O (1) 作業。

適用於