Stack in C# represents a last-in, first-out (LIFO) collection of objects. It is useful when you need last-in, first-out access to elements. Adding an element to the stack is called a push operation, and removing an element from the stack is called a pop operation.
A Stack is a collection that can be both generic and non-generic. The generic stack is defined in the System.Collections.Generic
namespace. A non-generic stack, on the other hand, is defined under System.Collections
namespace. In this post, we will discuss a non-generic type stack.