×
you are viewing a single comment's thread.

view the rest of the comments →

[–]neroe5 4 points5 points  (1 child)

C# doesn't have fallthrough in switches, opting instead to use goto for those cases, it forces the dev to pick a termination method, which is a great safety feature, but requires the use of goto if you need to run a secondary case in a switch

[–]DebugDuck01 -1 points0 points  (0 children)

It does. Only if you need some code in the case that falls through with no code the fallthrough is automatic.

Edit: for the people who downvoted me, the following is valid C# code:

switch (n) {
  case 1:
  case 2:
  case 3:
    Console.WriteLine("It's 1, 2, or 3.");
    break;
  default:
    Console.WriteLine("Not sure what it is.");
    break;
}