Stack:
It represents a last-in, first out collection of object. It is used when you need a last-in, first-out access of items. When you add an item in the list, it is called pushing the item and when you remove it, it is called popping the item.
Code:
It represents a last-in, first out collection of object. It is used when you need a last-in, first-out access of items. When you add an item in the list, it is called pushing the item and when you remove it, it is called popping the item.
Code:
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- using System.Collections;
- namespace sortedList
- {
- class Program
- {
- static void Main(string[] args)
- {
- Stack st = new Stack();
- st.Push("Sujan");
- st.Push(003);
- st.Push("Shakil");
- st.Push("Shimul");
- st.Push(01);
- st.Push(02);
- sprint(st);
- st.Pop();
- st.Pop();
- sprint(st);
- Console.ReadKey();
- }
- public static void sprint(Stack stack)
- {
- foreach (var i in stack)
- {
- Console.WriteLine(i);
- }
- }
- }
- }
0 Comments:
Post a Comment