I am somewhat new to C# and I ran into a problem in a small program I am
writing for teaching myself.
I am handling a list ob objects and I want to delete some of them inside
a loop like in:
foreach (Object object in objList)
{
if (object.status() == deleted)
{
objList.remove(object);
}
}
The problem here is that the list is changed while iterating over its
elements. I know one could make this work in C++ because the remove
method of the C++ STL list template returned an iterator to the next
valid object of the list. Is there any equivalent or other elegant
solution to do something like this?
I have read through all documentation I could find about the list class
in the past two days but I didn't find anything and I don't have much
literature on C# yet either.
Any help would be appreciated.