Implementation of C# Queue class
Program.cs
using System.Collections;

Queue q = new Queue();
q.Enqueue("Cherry");
q.Enqueue(65655);
q.Enqueue(45588);
q.Enqueue("Apple");

Console.Write("Queue elements: ");
foreach (var s in q)
{
    Console.Write(s + " ");
}

Console.WriteLine("\nFront element: " + q.Peek());
Console.WriteLine("Dequeue: element: " + q.Dequeue());
Console.WriteLine("Front element: " + q.Peek());
Console.WriteLine("Number of elements: " + q.Count);
Output
kodingwindow@kw:~/csharp$ dotnet run
Queue elements: Cherry 65655 45588 Apple 
Front element: Cherry
Dequeue: element: Cherry
Front element: 65655
Number of elements: 3
kodingwindow@kw:~/csharp$ 
Advertisement