Stack

Stack concepts in dotnet
Stack is a collection that works on the Last In First Out (LIFO) principle,
i.e., the last item inserted is the first item removed from the collection.
Push=> To add element and
Pop=> To Remove element
ook this example

See the below program you understand clearly
using System;
using System.Collections;
class Test
{
static void Main()
{
Stack stack = new Stack();
stack.Push(2);
stack.Push(4);
stack.Push(6);
while(stack.Count != 0)
{
Console.WriteLine(stack.Pop());
}
}
}

Output
6
4
2

No comments: