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

定義

判斷 SortedList<TKey,TValue> 是否包含特定值。Determines whether the SortedList<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

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

傳回

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

備註

這個方法會使用實數值型別Comparer<T>.Default TValue的預設比較子來判斷是否相等。This method determines equality using the default comparer Comparer<T>.Default for the value type TValue. Comparer<T>.Default檢查實值型TValue別是否會實行System.IComparable<T>並使用該執行(如果有的話)。Comparer<T>.Default checks whether the value type TValue implements System.IComparable<T> and uses that implementation, if available. 如果不是Comparer<T>.Default ,則會檢查實TValueSystem.IComparable型別是否會執行。If not, Comparer<T>.Default checks whether the value type TValue implements System.IComparable. 如果實值型TValue別不會執行任一介面,這個方法Object.Equals會使用。If the value type TValue does not implement either interface, this method uses Object.Equals.

這個方法會執行線性搜尋;因此,平均執行時間與成正比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.

適用於

另請參閱