I have a queue carrying class objects.Each class object has 3 string properties.In a loop i am checking with an If condition, on one of the class properties and on that basis i want to remove(dequeue) an object.
Suppose in c#.net and some pseudo code following is the scenario.
Foreach Loop to iterate through queue items
if myClassObj==(int)Class.Property1.ToString()
{
queue.Dequeue(this)
}
EndLoop
I get an exception saying that "Collection was modified after the enumerator was instantiated." Any one got idea about this? and also any alternates are welcome.Cheers
Exception in Queue while removing an element ?
2 Answers
Know the answer? Post it. Somebody with the same question will find it here.

Subhendu DeRank #1,108 · 1.7K reputationPosted Dec 9, 2010, 6:25 AM EST
http://stackoverflow.com/questions/2214446/how-can-i-modify-a-queue-collection-in-a-loop
If problem doesn't solve, ping me again.
Thanks.....
knights97 reputationPosted Dec 9, 2010, 9:01 AM EST