Compiler Error CS0158
TOC
Collapse the table of content
Expand the table of content
The document is archived and information here might be outdated

Compiler Error CS0158 

Error Message

The label 'label' shadows another label by the same name in a contained scope

A label in an inner scope hides a label with the same name in an outer scope. For more information, see goto (C# Reference).

The following sample generates CS0158:

// CS0158.cs
namespace MyNamespace
{
   public class MyClass
   {
      public static void Main()
      {
         goto lab1;
         lab1:
         {
            lab1:
            goto lab1;   // CS0158
         }
      }
   }
}
Show:
© 2016 Microsoft