2 ms·
The default behavior for a case within a switch statement should be to break. If you want to fall through to the next case, it should have been an explicit comm
by didgetmaster 3y ago
The default behavior for a case within a switch statement should be to break. If you want to fall through to the next case, it should have been an explicit command (e.g. fallthrough).
switch(x)
{
case 1: DoSomething();
case 2: DoSomethingElse();
case 3: SomePrep();
fallthrough;
case 4: DoMore();
default: DoNothing;
}
Only one statement needed to have case 3 fall through to case 4. No breaks needed at the end of any other cases.