Michael
Michael

Reputation: 85

Transversing through a queue data structure in C# without dequeuing it

Is there any way to transverse through all the elements of a queue without using dequeue function. i.e. without removing it elements?

Upvotes: 1

Views: 131

Answers (1)

Lee
Lee

Reputation: 144136

Queue<T> implements IEnumerable<T> so you can use foreach:

foreach(T item in queue)
{
}

Upvotes: 4

Related Questions