Collection was modified; enumeration operation may not execute c#

You will get this error when you are trying to remove list item in foreach loop.

either you have to use removeAll or removeAt.

It's good to iterate backward by index. like below,

for(int i = list.Count - 1; i >= 0; i--)
 if({some condition})

1 comment:

  1. Excellent Post. Also visit