how to use Goto Statement in C#

Total Post:341

Points:2389
C# 
C#
 902  View(s)
Ratings:
Rate this:
I want to use Goto Statement in C# please help me

  1. Post:281

    Points:2003
    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

    }

    }

    }

      Modified On Apr-10-2018 06:39:25 AM

Answer