The following code:
int 5 ; Goto B; // A goto statement is used to control the location of a tag. a++; B:console.writeline (a); Console.readkey ();
The output is: 5, execute goto, skip execution a++;
Goto and return jump out of the loop difference:
while(true) { intnum =Convert.ToInt32 (Console.ReadLine ()); if(num = =0) { GotoC; }} c:console.writeline ("jump out of the loop"); while(true) { intnum =Convert.ToInt32 (Console.ReadLine ()); if(num = =0) { return;//used to terminate the method, indicating that the method is running and that the remaining code does not execute the}} Console.WriteLine ("jump out of the loop"); Console.readkey ();
Comprehensive:
1>goto
The statement can jump to any place where the label is located to continue execution, it is worth noting that the label must be in the same function as the Goto statement, cannot cross the function body.
2>return
If a return statement is encountered in the program, the code exits the function's execution, returns to the function's call, and, if it is the main () function, ends the entire program's run.
C # Goto Learning