【发布时间】:2011-04-15 10:29:29
【问题描述】:
foreach (var shotItem in Invadershots)// it points to me to there and doesnt allow me to loop.."{"Collection was modified; enumeration operation may not execute."}"
{
shotItem.Move();// it happens when this simple method called (which actually checks some bool..if the shot was out of the winform).
if (shotItem.removeShot)
{
Invadershots.Remove(shotItem);
}
}
可能是因为我同时更改了列表项吗?
如何防止该错误发生?
【问题讨论】:
标签: c# winforms invalidoperationexception