What is Queue in detail?
Loading
Know the answer? Post it. Somebody with the same question will find it here.
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questions
DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend5days leftRegister
VulpesRank #55 · 29.2K reputationPosted Mar 18, 2014, 2:43 PM EDT
The output is:
Abhay ShankerRank #375 · 6.7K reputationPosted Mar 18, 2014, 10:10 PM EDT
Queue is a FIFO collection. It processes elements
in a first-in, first-out order.
The following table lists some of the commonly used
methods of the Queue class
The following example demonstrates use of Stack:
using System;
using System.Collections;
namespace CollectionsApp
{
class Program
{
static void Main(string[] args)
{
Queue q = new Queue();
q.Enqueue('A');
q.Enqueue('B');
q.Enqueue('C');
q.Enqueue('D');
Console.WriteLine("Current queue: ");
foreach (char c in q)
Console.Write(c + " ");
Console.WriteLine();
q.Enqueue('E');
q.Enqueue('E');
Console.WriteLine("Current queue: ");
foreach (char c in q)
Console.Write(c + " ");
Console.WriteLine();
Console.WriteLine("Removing some values ");
char ch = (char)q.Dequeue();
Console.WriteLine("The removed value: {0}", ch);
ch = (char)q.Dequeue();
Console.WriteLine("The removed value: {0}", ch);
Console.ReadKey();
}
}
}
When the above code is compiled and executed, it produces the following result:
Current queue:
A B C D
Current queue:
A B C D E F
Removing values
The removed value: A
The removed value: B