Goto Tester : Goto « Language Basics « C# / C Sharp






Goto Tester

Goto Tester
/*
Learning C# 
by Jesse Liberty

Publisher: O'Reilly 
ISBN: 0596003765
*/
 using System;
 public class GotoTester
 {

    public static void Main()
    {
       int counterVariable = 0;

       repeat:  // the label

       Console.WriteLine(
        "counterVariable: {0}",counterVariable);

       // increment the counter
       counterVariable++;

       if (counterVariable < 10)
         goto repeat;  // the dastardly deed
    }
 }

           
       








Related examples in the same category

1.Use goto with a switchUse goto with a switch
2.Demonstrate the gotoDemonstrate the goto
3.the goto statementthe goto statement