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
}
}
Collaborate with us on GitHub
The source for this content can be found on GitHub, where you can also create and review issues and pull requests. For more information, see our contributor guide.
.NET feedback
.NET is an open source project. Select a link to provide feedback: