C# Queue TrimToSize
Description
Queue TrimToSize
sets the capacity to the actual number
of elements in the Queue.
Syntax
Queue.TrimToSize
has the following syntax.
public virtual void TrimToSize()
Returns
Queue.TrimToSize
method returns
Example
/*from w w w . ja va2 s .c o m*/
using System;
using System.Collections;
public class SamplesQueue {
public static void Main() {
Queue mySourceQ = new Queue();
mySourceQ.Enqueue( "1" );
mySourceQ.Enqueue( "2" );
mySourceQ.Enqueue( "3" );
mySourceQ.TrimToSize();
}
}
The code above generates the following result.