C# Queue Clear

Description

Queue Clear removes all objects from the Queue.

Syntax

Queue.Clear has the following syntax.


public virtual void Clear()

Returns

Queue.Clear method returns

Example

The following example shows how to clear the values of the Queue.


// w  ww  .j  a va 2s.c om
using System;
using System.Collections;
public class SamplesQueue  {

   public static void Main()  {
      Queue myQ = new Queue();
      myQ.Enqueue( "1" );
      myQ.Enqueue( "2" );
      myQ.Enqueue( "3" );
      myQ.Enqueue( "4" );
      myQ.Enqueue( "5" );

      myQ.Clear();

      Console.WriteLine( "   Count    : {0}", myQ.Count );
   }
}

The code above generates the following result.





















Home »
  C# Tutorial »
    System.Collections »




ArrayList
BitArray
Comparer
Hashtable
Queue
SortedList
Stack