using System; using System.Collections; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace CSharpCollectionQueue { class Program { static void Main(string[] args) { //Initialize a Queue object Queue intQueue = new Queue(); // Populate the Queue //Insert in the queue the following values: //10, 20, 30 ,40 and 50 for (int i = 0; i < 5; i++) { intQueue.Enqueue((i + 1) * 10); } Console.WriteLine("Here are the items in the Queue: "); //Print each member of the Queue foreach (int i in intQueue) { Console.Write("{0} ", i.ToString()); } // Displays the first member of the Queue without removing it //The method Peek get the first element. //If we call "Peek" the second time we will get the second element (20) Console.Write("\nThe value of the first member is: {0} \n", intQueue.Peek().ToString()); // Removes the first item from the Queue and displays the remaining items intQueue.Dequeue(); Console.Write("The first item has now been removed. \nNow the remaining members are: "); //Print each member of the Queue foreach (int i in intQueue) { Console.Write("{0} ", i.ToString()); } System.Console.ReadKey(); } } }