Name
Stack.Contains Method
Class
System.Collections.Stack
Syntax
stackvariable
.Contains(obj
)
-
obj
Use: Required
Data Type: Any
The value to search for in the stack
Return Value
Boolean (True
or False
)
indicating whether obj
is found in the
stack
Description
Returns a Boolean indicating whether a given element (Object) is somewhere in the stack
Rules at a Glance
obj
must correspond exactly to an item in the stack for the method to returnTrue
.String comparison is case sensitive and is not affected by the setting of
Option
Compare
.The Contains method searches the stack sequentially. In other words, its performance is inversely proportional to the number of items in the stack.
Programming Tips and Gotchas
In comparing objects in the stack with
obj
, the Contains method in turn calls the BCL’s Object.Equals method to perform the comparison. The Equals method returnsTrue
if two object instances are the same instance.
Get VB .NET Language in a Nutshell now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.