Razzo78
10/19/2017 - 12:32 PM

C# - Execute and remove elements from a collection

C# - Execute and remove elements from a collection in only one cycle

var itsCommands = new List<Command>();

while (itsCommands.Count > 0)
{
    Command c = (Command) itsCommands[0];
    c.Execute();
    itsCommands.RemoveAt(0);
}