Queue.Contains(Object) 方法

定义

确定某元素是否在 Queue 中。Determines whether an element is in the Queue.

public:
 virtual bool Contains(System::Object ^ obj);
public virtual bool Contains (object obj);
public virtual bool Contains (object? obj);
abstract member Contains : obj -> bool
override this.Contains : obj -> bool
Public Overridable Function Contains (obj As Object) As Boolean

参数

obj
Object

要在 Object 中定位的 QueueThe Object to locate in the Queue. 该值可以为 nullThe value can be null.

返回

Boolean

如果在 true 中找到 obj,则为 Queue;否则为 falsetrue if obj is found in the Queue; otherwise, false.

注解

此方法通过调用来确定相等性 Object.EqualsThis method determines equality by calling Object.Equals.

此方法执行线性搜索;因此,此方法是一个 O(n) 操作,其中 nCountThis method performs a linear search; therefore, this method is an O(n) operation, where n is Count.

从 .NET Framework 2.0 开始,此方法使用集合的对象的 EqualsCompareTo 方法 obj 来确定是否 item 存在。Starting with the .NET Framework 2.0, this method uses the collection's objects' Equals and CompareTo methods on obj to determine whether item exists. 在 .NET Framework 的早期版本中,此决定是通过对 Equals CompareTo obj 集合中的对象使用参数的和方法进行的。In the earlier versions of the .NET Framework, this determination was made by using the Equals and CompareTo methods of the obj parameter on the objects in the collection.

适用于