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






the goto statement

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);

  }

}

           
       








Related examples in the same category

1.Use goto with a switchUse goto with a switch
2.Demonstrate the gotoDemonstrate the goto
3.Goto TesterGoto Tester