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); }