C# Queue Queue(Int32)
Description
Queue
initializes a new
instance of the Queue
Syntax
public Queue(
int capacity
)
Parameters
capacity
- The initial number of elements that the Queuecan contain.
Example
using System;/*from w w w .j av a 2 s .c o m*/
using System.Collections.Generic;
class Example
{
public static void Main()
{
Queue<string> numbers = new Queue<string>(21);
numbers.Enqueue("one");
numbers.Enqueue("two");
numbers.Enqueue("three");
numbers.Enqueue("four");
numbers.Enqueue("five");
Queue<string> queueCopy = new Queue<string>(numbers.ToArray());
foreach( string number in queueCopy )
{
Console.WriteLine(number);
}
}
}
The code above generates the following result.