samedi 21 novembre 2015

Why should I use continue as opposed to an empty if statement?

For example: What is the disadvantage/advantage of using this block:

for(int i = 0; i < 10; i++)
{
   if(i < 9){}
   else Console.Writeline(i);
}

As opposed to this block:

for(int i = 0; i < 10; i++)
{
   if(i < 9)
   {
   continue;
   }
   Console.Writeline(i);
}

Considering their output is exactly the same.

Aucun commentaire:

Enregistrer un commentaire