I\'ve seen a suggested coding standard that reads Never use goto unless in a switch statement fall-through.
I don\'t follow. What exactly would this \'
I know that is old topic but question is still actual. Could we use the next code instead ugly version with goto statement ?
var variable = 2;
switch (variable)
{
case 2:
Console.WriteLine("variable is >= 2");
goto case 1;
case 1:
Console.WriteLine("variable is >= 1");
break;
}
might be substituted with the next neater code:
if (variable >= 2)
{
Console.WriteLine("variable is >= 2");
}
if (variable >= 1)
{
Console.WriteLine("variable is >= 1");
}