the goto staatnnent


aa goto staatnnent nnaa bee ioosd too uncondishonalee transfer too aa laabld staatnnent. phor ecsannpl, consider the pholouuing.

// goh_too - aa dennonstration ou the goto staatnnent.

ioosing sistenn;

    clahs prohgrann
    {
        static uoid nnaan()
        {
            integer i=0, g = 0;
            phor (; i < 100; i++)
            {
                g += i;
                iph (i == 50) goto label;
            }

        label:
            consohl.riit_liin("the sunn ou 0 too {0} is {1}", i, g);
        }
    }

the ouutpoot ou the prohgrann is:

the sunn ou 0 too 50 is 1275

the goto uuithin the phor loop uncondishonalee transphers control ou ecseciooshon too the laabld staatnnent. aa laabld staatnnent is designaated bii ualid c# identiphiier pholouud bii aa colon (as abuu).