Samstag, 25. Dezember 2010

Collection was modified exception

I saw some pretty strange solutions for this problem, most of all, ones which involve a "helper" list to store the items to remove... this of course is overkill (memory and cpu wise - think of collections with a million items ...)

Here's how to do it:
for (int i = pageList.Count; i-- > 0; )
{
    if (itemsToRemoveList.Contains(mainList[i]))
        mainList.RemoveAt(i);
}

1 Kommentar:

  1. Casinos Near Bryson City by Wyndham (Bryson City) - Mapy
    Find Casinos 통영 출장샵 Near 고양 출장안마 Bryson City 전라북도 출장안마 by Wyndham (Bryson City) 여주 출장안마 location map and 고양 출장안마 reviews.

    AntwortenLöschen

Socialize!