Check if an element is in the Queue in CSharp
Description
The following code shows how to check if an element is in the Queue.
Example
using System;// w w w . j a va 2 s . c om
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.