C# Queue Contains
Description
Queue Contains
determines whether an element is in the
Queue.
Syntax
Queue.Contains
has the following syntax.
public virtual bool Contains(
Object obj
)
Parameters
Queue.Contains
has the following parameters.
obj
- The Object to locate in the Queue. The value can be null.
Returns
Queue.Contains
method returns true if obj is found in the Queue; otherwise, false.
Example
/*from w ww .ja v a 2s . co m*/
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(myQ.Contains("5") );
}
}
The code above generates the following result.