Skip to content

Instantly share code, notes, and snippets.

@AndrewBarfield
Created April 30, 2012 09:08
Show Gist options
  • Save AndrewBarfield/2556734 to your computer and use it in GitHub Desktop.
Save AndrewBarfield/2556734 to your computer and use it in GitHub Desktop.
C#: System.Collections.Generic: Generic Queue
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace GenericQueue {
class Program {
static void Main(string[] args) {
// Creates and initializes a new Queue<string>.
Queue<string> myQ = new Queue<string>();
myQ.Enqueue( "First" );
myQ.Enqueue( "Second" );
myQ.Enqueue( "Third" );
myQ.Enqueue( "Forth" );
myQ.Enqueue( "Fifth" );
// Dequeue each item in the Queue<string>
int count = myQ.Count;
for ( int index = 0 ; index < count ; index++ ) {
Console.WriteLine( (string)myQ.Dequeue() );
}
// Allow user to read the Console
Console.Read();
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment