Saturday, December 22, 2007

Collection was modified; enumeration operation may not execute

I got the above error when doing some specific step of operation in the foreach loop. One of that operation is to modify the content of the enumerations. Pls note that I'm not removing any entry just changing its value.
The only way to get around this problem is to use the classic for loop. The resultant code is not as elegant as foreach but anyway works so np :)
Just 1 question doesn't foreach internally execute the classic for loop, then why is classic for loop possible but not foreach

No comments: