Stack in Visual Basic .NET

Stack is a collection of objects which you can add element to top of the stack and you can remove the element from the top

So Stack represents a simple last-in-first-out (LIFO) non-generic collection of objects.

When you add element to stack you call it PUSH
When you remove element from stack you call it POP

We will write small piece of code in VB.NET for Stack operations


Code explanation

Line 4: Defining the Stack
Line 6: PUSH the element to stack
Line 15: POP the element from stack
When you look at the output last added item is “Sunday” and it is removed first