stack<T> collection in c#

An example of stack<T> use in c#:

Stack<int> stack = new Stack <int>();
stack.Push(1);
stack.Push(2);
int x = stack.Pop() / / x is 2
int y = stack.Pop() / / y is 1

Enjoyed this post? Share it!

 

Leave a comment

Your email address will not be published.