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]))

Keine Kommentare:

Kommentar veröffentlichen