I am looking for a better pattern for working with a list of elements which each need processed and then depending on the outcome are removed from
Trace the elements to be removed with a property, and remove them all after process.
using System.Linq;
List _Group = new List();
// ... add elements
bool cond = true;
foreach (MyProperty currObj in _Group)
{
if (cond)
{
// SET - element can be deleted
currObj.REMOVE_ME = true;
}
}
// RESET
_Group.RemoveAll(r => r.REMOVE_ME);