Dictionary<TKey,TValue>.ValueCollection.ICollection<TValue>.Contains(TValue) Dictionary<TKey,TValue>.ValueCollection.ICollection<TValue>.Contains(TValue) Dictionary<TKey,TValue>.ValueCollection.ICollection<TValue>.Contains(TValue) Method

定义

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

 virtual bool System.Collections.Generic.ICollection<TValue>.Contains(TValue item) = System::Collections::Generic::ICollection<TValue>::Contains;
bool ICollection<TValue>.Contains (TValue item);
Function Contains (item As TValue) As Boolean Implements ICollection(Of TValue).Contains

参数

item
TValue TValue TValue

要在 ICollection<T> 中定位的对象。The object to locate in the ICollection<T>.

返回

如果在 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 (n) 运算, 其中nCountThis method is an O(n) operation, where n is Count.

适用于