Stack.Contains(Object) 方法
定义
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
参数
返回
如果在 Stack 中找到 obj,则为 true;否则为 false。true, if obj is found in the Stack; otherwise, false.
注解
此方法通过调用方法来确定相等性 Object.Equals 。This method determines equality by calling the Object.Equals method.
此方法执行线性搜索;因此,此方法是一个 O(n) 操作,其中 n 是 Count 。This method performs a linear search; therefore, this method is an O(n) operation, where n is Count.
从 .NET Framework 2.0 开始,此方法通过将 obj 参数传递到 Equals 集合中的各个对象的方法来测试是否相等。Starting with the .NET Framework 2.0, this method tests for equality by passing the obj argument to the Equals method of individual objects in the collection. 在 .NET Framework 的早期版本中,通过将集合中的各个项传递到参数的方法来进行确定 Equals obj 。In the earlier versions of the .NET Framework, this determination was made by using passing the individual items in the collection to the Equals method of the obj argument.