goto

Goto statements allow the program to transfer control to a specific section or code block. This is also called a labeled statement. The classic example is the Switch..case statement, which we discussed in the previous section. When an expression matches a case, the labeled criteria statements in that code block are executed:

for (int i = 1; i <= 10; i++)
{
if (i == 5)
{
goto number5;
}
Console.WriteLine(i);
}
number5:
Console.WriteLine("You are here because of Goto Label");
//Output
1
2
3
4
You are here because of Goto Label
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.133.141.219