Mega Code Archive

 
Categories / C# / Language Basics
 

The goto statement

/* Mastering Visual C# .NET by Jason Price, Mike Gunderloy Publisher: Sybex; ISBN: 0782129110 */ /*   Example4_15.cs illustrates the use of   the goto statement */ public class Example4_15 {   public static void Main()   {     int total = 0;     int counter = 0;     myLabel:     counter++;     total += counter;     System.Console.WriteLine("counter = " + counter);     if (counter < 5)     {       System.Console.WriteLine("goto myLabel");       goto myLabel;     }     System.Console.WriteLine("total = " + total);   } }