Mid Collections

How do you clear a Stack<T>?

Use the Clear() method to remove all elements.

stack.Clear();

After this, Count becomes 0, and the internal array is reset.

More from C# Programming Tutorial

All questions for this course