Created
April 30, 2012 09:08
-
-
Save AndrewBarfield/2556734 to your computer and use it in GitHub Desktop.
C#: System.Collections.Generic: Generic Queue
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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