Is there a better way of iterating over the same collections objects in an if/else condition than the following:
bool condition = DetermineConditionValue();
if(condition)
{
foreach(var v in variables)
{
PerformAction(v);
}
else
{
foreach(var v in variables)
{
PerformAnotherAction(v);
}
}
Is there a better way to avoid writing the loop twice?
Aucun commentaire:
Enregistrer un commentaire