Reputation: 85
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
Reputation: 144136
Queue<T>
implements IEnumerable<T>
so you can use foreach
:
foreach(T item in queue)
{
}
Upvotes: 4