//Stack demonstration
using System;
using System.Collections;
class Program
{
static void Main()
{
Stack stackObj=new Stack();
stackObj.Push(20);
stackObj.Push(30);
stackObj.Push(50);
stackObj.Push(40);
stackObj.Push(60);
stackObj.Push(80);
//To Print Stack Objects
Console.WriteLine();
foreach(object obj in stackObj)
{
Console.WriteLine((int)obj);
}
Console.WriteLine();
for(int i=0;i<stackObj.Count;i=i+0)
{
Console.WriteLine((int)stackObj.Pop());
}
}
}
No comments:
Post a Comment