Stack represents a last-in, first out collection of object.
Stack<T>.Contains(Object) Method is used to check whether an element is in the Stack<T> or not.
public virtual bool Contains(object obj);
Return Value: The function returns True if the element exists in the Stack<T> and returns False if the element doesn’t exist in the Stack.
Below given are some examples to understand the implementation in a better way:
- C# | Check if an element is in the Queue
- C# | Check if an element is in the Collection<T>
- C# | Check if a HashSet contains the specified element
- C# | How to check whether a List contains a specified element
- C# | Check if the SortedSet contains a specific element
- C# | Check whether an element is contained in the ArrayList
- C# | Check if every List element matches the predicate conditions
- C# | How to create a Stack
- C# Stack with Examples
- Stack.Pop() Method in C#
- Implementing Stack in C#
- Stack.Contains() Method in C#
- C# | Stack Class
- Stack.Push() Method in C#
- Stack.ToArray() Method in C#
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to email@example.com. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.