Demonstrate the goto : Goto « Language Basics « C# / C Sharp






Demonstrate the goto

Demonstrate the goto
/*
C#: The Complete Reference 
by Herbert Schildt 

Publisher: Osborne/McGraw-Hill (March 8, 2002)
ISBN: 0072134852
*/
// Demonstrate the goto. 
  
using System;  
  
public class Use_goto {     
  public static void Main() {     
    int i=0, j=0, k=0; 
 
    for(i=0; i < 10; i++) { 
      for(j=0; j < 10; j++ ) { 
        for(k=0; k < 10; k++) { 
          Console.WriteLine("i, j, k: " + i + " " + j + " " + k); 
          if(k == 3) goto stop; 
        } 
      } 
    } 
 
stop: 
    Console.WriteLine("Stopped! i, j, k: " + i + ", " + j + " " + k); 
    
  }  
}


           
       








Related examples in the same category

1.Use goto with a switchUse goto with a switch
2.Goto TesterGoto Tester
3.the goto statementthe goto statement