CS0163 de erro do compilador

Mensagem de erro

Controle não pode passar de um rótulo caso ('Rótulo') para outro

When a case statement contains one or more statements and is followed by another case statement, you must explicitly terminate the case by using one of the following keywords:

  • return

  • goto

  • break

  • throw

  • continue

Se desejar implementar comportamento "se", usegoto case #. Para mais informações, consulte: Alternar (referência C#).

O exemplo a seguir gera CS0163:

// CS0163.cs
public class MyClass
{
   public static void Main()
   {
      int i = 0;

      switch (i)   // CS0163
      {
         case 1:
            i++;
            // uncomment one of the following lines to resolve
            // return;
            // break;
            // goto case 3;

         case 2:
            i++;
            return;

         case 3:
            i = 0;
            return;
      }
   }
}