Generic Stack collection class C sharp Arabic #82

 


Generic Stack collection class C sharp Arabic #82

Suggested Videos




Generic Stack collection class

Stack a is generic LIFO(Last in First Out) collection class that is present in System .Collections.Generic namespace . The Stack collection class is analogous to A stack of plates. If you want to add a new plate to the stack of plates, you place it on top of all the already existing plates. If you want to remove a plate from the stack , you will first remove the one that you have last added . The stack collection class also operates in a similar fashion. The last item To be added (pushed) to the stack ,will be the first item to be removed (popped) from the stack.

To insert an item at the top of the stack ,use Push() method.

To remove and return the item that is present at the top of the stack, use Pop() method.

A foreach loop iterates thru the items in the stack, but will not remove them the stack. The items from the stack are retrieved in LIFO(Last in First Out), order . The last element added to the Stack is the first one to be returned.

To check if an item, exists in the stack , use Contains() method.

What is the difference between Pop() and Peek() methods?

Pop() method removes and returns the item at the beginning of the stack, where as Peek() returns the item at the top of the stack, without removing it.

Follow Us

YouTube

 If you want to download pptx : click Telegram

Facebook

Twitter

Instagram

Tik Tok

إرسال تعليق

أحدث أقدم