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# | How to check whether a List contains a specified element
- C# | Check if a HashSet contains the specified element
- C# | Check if an element is in the Queue
- C# | Check if an element is in the Collection<T>
- 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# Stack with Examples
- C# | How to create a Stack
- Implementing Stack in C#
- Stack.Contains() Method in C#
- Stack.Pop() Method in C#
- C# | Stack Class
- C# | Convert Stack to array
- C# | Remove all objects from the Stack
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.