This documentation is archived and is not being maintained.

Stack.Contains Method

Determines whether an element is in the Stack.

[Visual Basic]
Public Overridable Function Contains( _
   ByVal obj As Object _
) As Boolean
public virtual bool Contains(
 object obj
public: virtual bool Contains(
 Object* obj
public function Contains(
   obj : Object
) : Boolean;


The Object to locate in the Stack. The value can be a null reference (Nothing in Visual Basic).

Return Value

true if obj is found in the Stack; otherwise, false.


This method performs a linear search; therefore, the average execution time is proportional to Count. That is, this method is an O(n) operation, where n is Count.

This method determines equality by calling Object.Equals.


Platforms: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 family

See Also

Stack Class | Stack Members | System.Collections Namespace | Performing Culture-Insensitive String Operations