ICollection<T>.Contains(T) ICollection<T>.Contains(T) ICollection<T>.Contains(T) ICollection<T>.Contains(T) Method

定义

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

public:
 bool Contains(T item);
public bool Contains (T item);
abstract member Contains : 'T -> bool
Public Function Contains (item As T) As Boolean

参数

item

要在 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>使用Comparer<T>.Default, 而Dictionary<TKey,TValue>允许用户指定IComparer<T>要用于比较键的实现。Implementations can vary in how they determine equality of objects; for example, List<T> uses Comparer<T>.Default, whereas Dictionary<TKey,TValue> allows the user to specify the IComparer<T> implementation to use for comparing keys.

适用于