Hi Programmers , Welcome to new Article of Ozanecare. This article i am going to explain Stack programming in c#.net. In c# we should use Stack class , It is based on the principle of LIFO (Last in First Out). The two important methods used push and pop. the push method pushes an element on the top of the stack. pop method removes and returns top of the element in the Stack. see below image.
Example 1 of Stack Programming.
peek method returns top of the element in the Stack.
count method count total numbers of element in stack.
Contains method check element present in the stack or not. if present then return true else false. see below image.
Example 2 of Stack Programming. clear method is used to remove elements from stack. see below image.