C# Queue Count
Description
Queue
gets the number of elements contained
in the Queue
Syntax
Queue.Count
has the following syntax.
public int Count { get; }
Example
using System;// w ww . j a v a 2s.c o m
using System.Collections.Generic;
class Example
{
public static void Main()
{
Queue<string> numbers = new Queue<string>();
numbers.Enqueue("one");
numbers.Enqueue("two");
numbers.Enqueue("three");
numbers.Enqueue("four");
numbers.Enqueue("five");
foreach( string number in numbers )
{
Console.WriteLine(number);
}
Console.WriteLine("\nqueueCopy.Count = {0}", numbers.Count);
}
}
The code above generates the following result.