HOW TO USE GOTO STATEMENT IN C#

Ankit Singh

Total Post:341

Points:2389
Posted by  Ankit Singh
C# 
C#
 535  View(s)
Ratings:
Rate this:
I want to use Goto Statement in C# please help me

  1. aditya kumar Patel

    Post:254

    Points:1810
    Re: how to use Goto Statement in C#

    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

    }

    }

    }

Answer

NEWSLETTER

Enter your email address here always to be updated. We promise not to spam!