Edit

Share via


Compiler Error CS0159

No such label 'label' within the scope of the goto statement

The label referenced by the goto statement could not be found within the scope of the goto statement.

The following sample generates CS0159:

// CS0159.cs  
public class Class1  
{  
   public static void Main()  
   {  
      int i = 0;  
  
      switch (i)  
      {  
         case 1:  
            goto case 3;   // CS0159, case 3 label does not exist  
         case 2:  
            break;  
      }  
      goto NOWHERE;   // CS0159, NOWHERE label does not exist  
   }  
}