Possible duplicates:
Exception during iteration when collecting and removing items from this collection
How to remove items from the general list during iteration around it?
Best way to remove matching items from a list
// tmpClientList is List<Client> type if (txtboxClientName.Text != "") foreach (Client cli in tmpClientList) if (cli.Name != txtboxClientName.Text) tmpClientList.Remove(cli);
Error: "The collection has been modified; the enumeration operation may not be performed."
How can I remove elements from a list in a simple way without storing the indices of these elements in another list or array and deleting them elsewhere in the code. I also tried RemoveAt (index), but this is exactly the same situation, changing when the loop starts.
c #
qlf00n
source share