Mega Code Archive

 
Categories / C# Tutorial / Statement
 

The use of the goto statement in a if statement

class MainClass {   public static void Main()   {     int total = 0;     int counter = 0;     myLabel:     counter++;     total += counter;     if (counter < 5)     {       System.Console.WriteLine(counter);       goto myLabel;     }   } } 1 2 3 4