C and C ++ allow the case label in the switch statement without the break statement, so that you can continue to execute the following statement after case. However, this is often because programmers forget to write break statements and become an undiscoverable vulnerability. Therefore, C # does not allow this. It requires that each label item use the break statement or jump statement goto, that is, it is not allowed to automatically traverse from one case to other cases. Otherwise, an error is reported during compilation, even after the default statement.
This determines three features:
A) We can arrange case items in any switch statement without affecting the switch statement function.
B) If you want to traverse other statements after execution like c/c ++, add one of the following two jump statements after the case statement: goto case label; goto default.
3) Besides goto, throw and return can also be used.
Another difference between the C # switch statement and C/C ++ is that C # uses string constants as constant expressions like VB, but C/C ++ does not. So in C #, case "OK": This form is also supported.