Why I get the error as collection was modified an enumeration opearation may not execute while releasing the application in C#?
Asked
Active
Viewed 85 times
-2
-
1Please read [faq] and [ask] a couple of times.. – Soner Gönül Jan 18 '13 at 10:00
-
1Then read http://tinyurl.com/so-list and http://tinyurl.com/so-hints – Jon Skeet Jan 18 '13 at 10:01
-
1+1 the other comments and code always helps! – Belogix Jan 18 '13 at 10:02
-
@user1511049 Moreover, consider to write a question, not a chat message! You have to read two or three times your questions before to submit! Please, consider an edit with more details! – JeanValjean Jan 18 '13 at 10:02
-
This could be helpful: [http://stackoverflow.com/a/759985/674700](http://stackoverflow.com/a/759985/674700) – Alex Filipovici Jan 18 '13 at 10:10
1 Answers
2
it means you directly/indirectly tries to change one of references to objects in your collection.
in an iteration:
foreach(var item in myCollection)
{
item = new Item(); // Error
item.Prop = "Something"; //OK
}

Karim
- 150
- 6