SortedList<TKey,TValue>.ContainsValue(TValue) 方法

定义

确定 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

要在 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 ,则检查值类型TValue是否System.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.

适用于

另请参阅