Dictionary<TKey,TValue>.ContainsValue(TValue) Dictionary<TKey,TValue>.ContainsValue(TValue) Dictionary<TKey,TValue>.ContainsValue(TValue) Dictionary<TKey,TValue>.ContainsValue(TValue) Method

定義

判斷 Dictionary<TKey,TValue> 是否包含特定值。Determines whether the Dictionary<TKey,TValue> contains a specific value.

public:
 bool ContainsValue(TValue value);
public bool ContainsValue (TValue value);
member this.ContainsValue : 'Value -> bool
Public Function ContainsValue (value As TValue) As Boolean

參數

value
TValue TValue TValue TValue

要在 Dictionary<TKey,TValue> 中尋找的值。The value to locate in the Dictionary<TKey,TValue>. 參考類型的值可以是 nullThe value can be null for reference types.

傳回

如果 true 包含具有指定值的項目,則為 Dictionary<TKey,TValue>,否則為 falsetrue if the Dictionary<TKey,TValue> contains an element with the specified value; otherwise, false.

備註

這個方法會使用的預設相等比較EqualityComparer<T>.Default子(也就是字典中的數值型別)來TValue判斷是否相等。This method determines equality using the default equality comparer EqualityComparer<T>.Default for TValue, the type of values in the dictionary.

這個方法會執行線性搜尋;因此,平均執行時間與成正比CountThis method performs a linear search; therefore, the average execution time is proportional to Count. 也就是說,這個方法是 O (n)運算,其中nCountThat is, this method is an O(n) operation, where n is Count.

適用於

另請參閱