Demonstrate the goto. : Goto « Statement « C# / CSharp Tutorial






using System;  
  
class MainClass {     
  public static void Main() {     
    for(int i=0; i < 10; i++) { 
      Console.WriteLine("i" + i); 
      if(i == 3) 
          goto stop; 
    } 
stop: 
    Console.WriteLine("Stopped!"); 
    
  }  
}
i0
i1
i2
i3
Stopped!








4.9.Goto
4.9.1.Use goto with a switch
4.9.2.Demonstrate the goto.
4.9.3.While with goto statement
4.9.4.The use of the goto statement in a if statement