Stack Collection Types
Theclass and the generic class are last-in-first-out collection classes that implement the interface. The Stack generic class also implements the generic interface.
Stacks and queues are useful when you need temporary storage for information, that is, when you might want to discard an element after retrieving its value. Use Queue if you need to access the information in the same order that it is stored in the collection. Use Stack if you need to access the information in reverse order.
A common use for a Stack is preserving variable states during calls to other procedures.
Three main operations can be performed on a Stack and its elements:
Push inserts an element at the top of the Stack.
Pop removes an element at the top of the Stack.
Peek returns an element at the top of the Stack but does not remove it from the Stack.