Alex Rivera | Logout

How can I check if a Queue is empty?

Asked 2011-11-01T15:17:04.107
48

In C#, how can I check if a Queue is empty?

I want to iterate through the Queue's elements, and I need to know when to stop. How can I accomplish this?

Edit
Report

1 Answer

10

Assuming you meant System.Collections.Generic.Queue<T>

if(yourQueue.Count != 0) { /* Whatever */ }

should do the trick.

answered 2011-11-01T15:18:42.030

Your Answer