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

定义

确定 ICollection<T> 是否包含特定值。Determines whether the ICollection<T> contains a specific value.

 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> 中定位的对象。The object to locate in the ICollection<T>.

返回

Boolean

如果在 true 中找到 item,则为 ICollection<T>;否则为 falsetrue if item is found in the ICollection<T>; otherwise, false.

实现

注解

在如何确定对象是否相等方面这些实现可能存在差异;例如,List<T> 使用 Default,而 Dictionary<TKey,TValue> 允许用户指定 IComparer<T> 实现以用来对键进行比较。Implementations can vary in how they determine equality of objects; for example, List<T> uses Default, whereas, Dictionary<TKey,TValue> allows the user to specify the IComparer<T> implementation to use for comparing keys.

此方法是 O (1) 操作。This method is an O(1) operation.

适用于