Enqueue and dequeue : Queue « Data Structure « C# / CSharp Tutorial






using System; 
using System.Collections; 
  
class MainClass { 
 
  public static void Main() { 
    Queue q = new Queue(); 
 
    q.Enqueue(1); 
    q.Enqueue(2); 
    q.Enqueue(3); 
    q.Enqueue(4); 
 
    Console.Write("queue: "); 
    foreach(int i in q) 
      Console.Write(i + " "); 
 
    Console.WriteLine();         

    Console.Write("Dequeue -> "); 
    int a = (int) q.Dequeue(); 
    Console.WriteLine(a); 
 
    Console.Write("queue: "); 
    foreach(int i in q) 
      Console.Write(i + " "); 
 
    Console.WriteLine();         
 
  } 
}
queue: 1 2 3 4
Dequeue -> 1
queue: 2 3 4








11.38.Queue
11.38.1.Enqueue and dequeue
11.38.2.Clear a Queue
11.38.3.Peek a queue
11.38.4.Creating a list from a queue
11.38.5.Dequeue and Peek
11.38.6.Queue<(Of <(T>)>) generic class, including the ToArray method.
11.38.7.Queue<(Of <(T>)>) generic class, the Dequeue method.