Represents a first-in, first-out collection of objects.
public class Queue: Object, ICollection, ICloneable
ObjectQueue
// This sample shows how to implement the Queue class.
using System.Diagnostics;
using System.Collections;
public class SampleQueue
{
static void Main()
{
// Creates a new Queue.
Queue myDaysQueue = new Queue();
// Initializes for the Queue.
myDaysQueue.Enqueue("Monday");
myDaysQueue.Enqueue("Tuesday");
myDaysQueue.Enqueue("Wednesday");
myDaysQueue.Enqueue("Thursday");
myDaysQueue.Enqueue("Friday");
myDaysQueue.Enqueue("Saturday");
myDaysQueue.Enqueue("Sunday");
// Displaying .
Debug.WriteLine("The number of elements in the Queue: " + myDaysQueue.Count);
Debug.WriteLine("\nThe values of the Queue:");
DisplayQueue(myDaysQueue
);}
static void DisplayQueue(IEnumerable myCollection )
{
IEnumerator myIEnum = myCollection.GetEnumerator();
Debug.WriteLine("\t\t" +myIEnum.Current);
}
}
/*
The output of the sample.
The number of elements in the Queue: 7
The value of the Queue:
Monday
Tuesday
Wednesday
Thursday
Friday
Saturday
Sunday
*/
Namespace System.Collections Flash Library corlib.scl Flash Library Version 2.0.0.2466 Silverlight Library System.Windows.Forms.dll
| © 2003-2007 NETiKA Technologies. All rights reserved. |