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>,否則為 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.

適用於