0
What are the uses of stack and queue in C# and how to implements them in the C# program?
What are the uses of stack and queue in C# and how to implements them in the C# program?
using System;
using System.Collections;
public class Program
{
public static void Main()
{
Stack stack=new Stack();
stack.Push(45);
stack.Push(12);
stack.Push(125);
stack.Push(102);
foreach(var item in stack)
Console.WriteLine(item);
}
}
102
125
12
45
using System;
using System.Collections;
public class Program
{
public static void Main()
{
Queue queue=new Queue();
queue.Enqueue(45);
queue.Enqueue(12);
queue.Enqueue(125);
queue.Enqueue(102);
foreach(var item in queue)
Console.WriteLine(item);
}
}
45
12
125
102