C# Queue Contains
Description
Queue
determines whether an element
is in the Queue
Syntax
Queue.Contains
has the following syntax.
public bool Contains(
T item
)
Parameters
Queue.Contains
has the following parameters.
item
- The object to locate in the Queue. The value can be null for reference types.
Returns
Queue.Contains
method returns true if item is found in the Queue; otherwise, false.
Example
using System;//from ww w.jav 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");
Console.WriteLine(numbers.Contains("four"));
}
}
The code above generates the following result.