Home > DeveloperSection > Forums > how to use Goto Statement in C#
Ankit Singh

Total Post:341

Points:2389
Posted on    December-16-2015 10:21 PM

 C# C# 
Ratings:


 1 Reply(s)
 216  View(s)
Rate this:
I want to use Goto Statement in C# please help me



aditya kumar Patel

Total Post:246

Points:1752
Posted on    December-16-2015 10:27 PM

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

using System;

namespace goto_statement

{

class Program

{

static void Main(string[] args)

{

string ClassName;

GetReStart: //creating GetStart with colon(:)

Console.WriteLine("Enter Class Name:");

ClassName = Console.ReadLine();

Console.WriteLine("I am a final year {0} student ", ClassName);

goto GetReStart; //jump to GetReStart statement

}

}

}


Don't want to miss updates? Please click the below button!

Follow MindStick