C# switch/break

break, c#, switch-statement

Solution

Yes, you can fall through to the next case block in two ways. You can use empty cases, which don't need a break, or you can use `goto` to jump to the next (or any) case:

switch (n) {
  case 1:
  case 2:
  case 3:
    Console.WriteLine("1, 2 or 3");
    goto case 4;
  case 4:
    Console.WriteLine(4);
    break;
}

Problem

It appears I need to use a break in each case block in my switch statement using C#. I can see the reason for this in other languages where you can fall through to the next case statement. Is it possible for case blocks to fall through to other case blocks? Thanks very much, really appreciated!

Original source

Related problems