goto statement

goto statement jumps to another labeled location.

goto statement has the form of


goto label;

When using with switch statement its form is


goto case caseConstant;
 
using System;

class Program
{
    static void Main(string[] args)
    {
        for (int i = 0; i < 10; i++)
        {
            if (i == 1)
            {
                goto end;
            }
        }
    end: Console.WriteLine("The end");

    }
}

The output:


The end
java2s.com  |  | Contact Us | Privacy Policy
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.