C# Queue Enqueue
Description
Queue Enqueue
adds an object to the end of the Queue.
Syntax
Queue.Enqueue
has the following syntax.
public virtual void Enqueue(
Object obj
)
Parameters
Queue.Enqueue
has the following parameters.
obj
- The object to add to the Queue. The value can be null.
Returns
Queue.Enqueue
method returns
Example
The following example shows how to add elements to the Queue.
/* w w w . jav a 2 s . c om*/
using System;
using System.Collections;
public class SamplesQueue {
public static void Main() {
// Creates and initializes a new Queue.
Queue myQ = new Queue();
myQ.Enqueue( "The" );
myQ.Enqueue( "quick" );
myQ.Enqueue( "brown" );
myQ.Enqueue( "fox" );
foreach ( Object obj in myQ )
Console.WriteLine( " {0}", obj );
}
}
The code above generates the following result.