- Trending Categories
- Data Structure
- Networking
- RDBMS
- Operating System
- Java
- MS Excel
- iOS
- HTML
- CSS
- Android
- Python
- C Programming
- C++
- C#
- MongoDB
- MySQL
- Javascript
- PHP
- Physics
- Chemistry
- Biology
- Mathematics
- English
- Economics
- Psychology
- Social Studies
- Fashion Studies
- Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Stack Class in C#
Stack class represents a last-in, first out collection of object. It is used when you need a last-in, first-out access of items.
The following is the property of Stack class −
Count − Gets the number of elements in the stack.
The following are the methods of Stack class −
Sr.No. | Method & Description |
---|---|
1 | public virtual void Clear(); Removes all elements from the Stack. |
2 | public virtual bool Contains(object obj); Determines whether an element is in the Stack. |
3 | public virtual object Peek(); Returns the object at the top of the Stack without removing it. |
4 | public virtual object Pop(); Removes and returns the object at the top of the Stack. |
5 | public virtual void Push(object obj); Inserts an object at the top of the Stack. |
6 | public virtual object[] ToArray(); Copies the Stack to a new array. |
Advertisements