In C#, the GOTO statement is used to point control to the label for iteration without using the loop. First, you need to create a label by just specifying the colon (:) at the end of the label name and then mention its name with GOTO command. Below are the syntax and example.
Syntax
goto lable_name;
Example
using System; namespace GoToExample { class GoToExample { static void Main(string[] args) { int i = 0; label_repeat: // label Console.WriteLine("i: {0}", i); i++; if (i < 10) goto label_repeat; Console.ReadLine(); return; } } }
Output
i: 0 i: 1 i: 2 i: 3 i: 4 i: 5 i: 6 i: 7 i: 8 i: 9