C# Compiler Error
CS0140 – The label ‘label’ is a duplicate
Reason for the Error
This error is specific to the the usage of goto statement in C#. When you have defined more than one label with-in the same scope, you will receive this error.
For example, try compiling the below C# code snippet.
namespace DeveloperPublishNamespace { public class DeveloperPublish { public static void Main() { goto FirstLabel; FirstLabel: System.Console.WriteLine("First Label"); FirstLabel: System.Console.WriteLine("Second Label"); } } }
You will receive the C# Error CS0140 because we have defined two labels with the same name “FirstLabel” with-in the Main function.
Error CS0140 The label ‘FirstLabel’ is a duplicate ConsoleApp1 C:\Users\SenthilBalu\source\repos\ConsoleApp1\ConsoleApp1\Program.cs 9 Active
Solution
To fix this error, rename the duplicate label to something different from the other label.