K
Keith O
Assume fooList is an ArrayList
foreach(string s in fooList) {
if (some condition) {
fooList.Remove(s);
}
}
I get the following runtime error:
An unhandled exception of type 'System.InvalidOperationException' occurred
in mscorlib.dll
Additional information: Collection was modified; enumeration operation may
not execute.
How can I fix this?
Thanks
foreach(string s in fooList) {
if (some condition) {
fooList.Remove(s);
}
}
I get the following runtime error:
An unhandled exception of type 'System.InvalidOperationException' occurred
in mscorlib.dll
Additional information: Collection was modified; enumeration operation may
not execute.
How can I fix this?
Thanks