The code below does the functionality where you can have a explicit fall through case blocks.
public static void Main()
{
int x = 3;
switch(x)
{
case 0:
// do something
goto case 1;
case 1:
// do something in common with 0
goto default;
default:
// do something in common with 0, 1, and anything else
break;
}
}
}
Note:-Fall through means if you didn't write any statement in case 0, control automatically go to next case, which is not supported by c#, and we need to use goto statement to send control to next case
No comments:
Post a Comment