ICollection<T>.Contains(T) 方法
定义
确定 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
- T
要在 ICollection<T> 中定位的对象。The object to locate in the ICollection<T>.
返回
如果在 true 中找到 item,则为 ICollection<T>;否则为 false。true 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.