Goto Keyword | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

Goto Keyword

In C# we can use the keyword goto, I would like to know how does it really work?

3rd Feb 2017, 3:42 PM
Stanislau Ebo da Silva
1 Answer
+ 2
goto is used to move to a line in the code using a label for it. let's talk with example: int x=3; int y=5; for (int i=1;i <=10;i++) { if (i == 5) goto fiveIsEnough; Console.Write (i); } fiveIsEnough: Console.write(x + y); Now the output is -> 12348 where 8 is result of sum x and y
3rd Feb 2017, 6:59 PM
Ahmad Hamdan
Ahmad Hamdan - avatar