C# Goto Statement

goto-label
In this chapter you will learn:

  • What is goto statement in C#?
  • What is the functionality of goto statement?
  • How to use goto statement in C# programming?

The goto statement is a jump statement that controls the execution of the program to another segment of the same program. You create label at anywhere in program then can pass the execution control via the goto statements.

Example:


Note: To terminate the program press Ctrl+C

Output

Enter your name :
Steven
Welcome Steven
Press Ctrl + C for ExitEnter your name :
Clark
Welcome Clark
Press Ctrl + C for ExitEnter your name :
Steven Clark
Welcome Steven Clark
Press Ctrl + C for Exit

Enter your name : __

Summary

In this chapter, you learned what goto statement is in C# and how to use it in programming. In next chapter you will learn about break statement in C#.


One thought on “C# Goto Statement”

Leave a Reply

Your email address will not be published. Required fields are marked *