The collection has been modified, enumeration operation may not be performed

the reason:

Do not delete or add a set of operations in the foreach

When the cycle, when the collection is deleted an item, then the total count and the index will change, so will complain

Solution:

Do not perform operations on the set of enumeration List (eg foreach) to modify operation of the collection. To change the set to use the ToArray () method is converted into Array

Or add to the contents of the operation in the operation list

 

Guess you like

Origin www.cnblogs.com/missheyo/p/10944764.html