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.

適用於