-2

Why I get the error as collection was modified an enumeration opearation may not execute while releasing the application in C#?

JeanValjean
  • 16,558
  • 22
  • 110
  • 151

1 Answers1

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