Put elements into a queue : Queue « Collections Data Structure « C# / C Sharp






Put elements into a queue

    

using System;
using System.Collections;
using System.Collections.Generic;
using System.Text;

class Program {
    static void Main(string[] args) {
        Queue alphabet = new Queue();
        alphabet.Enqueue("A");
        alphabet.Enqueue("B");
        alphabet.Enqueue("C");

        Console.Write("First Iteration: ");

        foreach (string item in alphabet) {
            Console.Write(item);
        }

        Console.WriteLine("\nItem pulled from collection: " +
           alphabet.Dequeue().ToString());
        Console.Write("Second iteration: ");

        foreach (string item in alphabet) {
            Console.Write(item);
        }
    }
}

   
    
    
  








Related examples in the same category

1.Put user-defined objects to Queue collection
2.Implements the queue data type using an arrayImplements the queue data type using an array
3.A queue class for charactersA queue class for characters
4.illustrates the use of a Queueillustrates the use of a Queue
5.Queue testQueue test
6.Add exception handling to the queue classesAdd exception handling to the queue classes
7.Demonstrate the Queue classDemonstrate the Queue class
8.Priority Queue
9.Queue(T) Class represents a first-in, first-out collection of objects.
10.Priority Queue (2)
11.Dequeue
12.Implements a non-locking queue
13.Task queue
14.Cyclic Queue
15.Syncronized Queue