Mid From PDF Collections C# Collections

What methods are available in a Stack<T> for adding and removing elements?

Method Description

Push() Adds an element to the top

Pop() Removes and returns the top element

Peek() Returns top element without removing it

Clear(

Removes all elements

Example:

stack.Push(100); // Add

int top = stack.Pop(); // Remove and return top

More from C# Programming Tutorial

All questions for this course
Toolliyo Assistant
Ask about tutorials, ebooks, training, pricing, mentor services, and support. I use public site content only—not admin or internal tools.

care@toolliyo.com

Need callback? Share your details