So I have some C# code that looks like this:
while(condition)
{
switch(anumber)
{
case 0:
//do something
break;
case 1:
//do something
break;
//and so on
}
}
Being a noob at programming, I recently added the keyword continue
to my vocabulary. After doing some research I came across this:
the continue statement relates to the enclosing loop
So my code should work like this as well:
while(condition)
{
switch(anumber)
{
case 0:
//do something
continue;
//and so on
}
}
But writing code that just gives no compiler error is not everything. Is using continue
in a loop enclosed switch block a good idea? Is there any difference in, for example, performance or are these just two syntactically different but otherwise quite similar ways to achieve the same result?