C# Compiler Error
CS0159 – No such label ‘label’ within the scope of the goto statement
Reason for the Error
You will receive this error in C# when you are using a label that is undefined.
The below code snippet demonstrates the C# error code CS0159 as the label “somewhere” is not defined with-in your program.
namespace ConsoleApp2 { public class DeveloperPublishException { } class Program { public static void Main() { goto somewhere; } } }
Error CS0159 No such label ‘somewhere’ within the scope of the goto statement ConsoleApp2 C:\Users\Senthil\source\repos\ConsoleApp1\ConsoleApp2\Program.cs 11 Active
Solution
Ensure that the label that you are using with the goto statement is defined with-in the scope where it is called.