Junior
From PDF
Collections
C# Collections
What is a Stack<T> in C#?
A Stack<T> is a generic collection in C# that stores elements in a Last-In, First-Out
(LIFO) order.
- The last element added is the first one removed
- Belongs to System.Collections.Generic
Real-world use case:
Undo operations, browser history, expression evaluation.
Example:
Stack<int> numbers = new Stack<int>();
numbers.Push(10);
numbers.Push(20); // Top of the stack
Share this Q&A
Share preview image: https://www.toolliyo.com/images/toolliyo-logo.png