C
Curious
Hi,
I have an array list in which some items are marked as "ShouldRemove".
When I loop through each item, I should remove these items. However, I
believe that I will get "Collection was modified; enumeration
operation may not execute" error.
foreach (BenchmarkPrice bp in mBenchmarkPriceList)
{
if (bp.ShouldRemove == true)
{
// This won't work because this alters the length
of the array list, mBenchmarkPriceList
mBenchmarkPriceList.Remove (bp);
}
}
Any advice on how to get this done safely?
I have an array list in which some items are marked as "ShouldRemove".
When I loop through each item, I should remove these items. However, I
believe that I will get "Collection was modified; enumeration
operation may not execute" error.
foreach (BenchmarkPrice bp in mBenchmarkPriceList)
{
if (bp.ShouldRemove == true)
{
// This won't work because this alters the length
of the array list, mBenchmarkPriceList
mBenchmarkPriceList.Remove (bp);
}
}
Any advice on how to get this done safely?