C# GoTO



Goto statement in c# 
is called as jumping statement and is used to jump from one location to another within the program.

To jump to a location directly, a label must be defined at that location and then we have to write goto label. Using goto is not recommended as it effects the performance of the application.


C# GoTo Example



using System;

namespace ProgramCall
{
    class IntReverse
    {
        static void Main()
        {
            int N, R = 0;

            Console.Write("Enter An Integer : ");
            N = int.Parse(Console.ReadLine());

            //label
            Reverse:

            R = R * 10 + N % 10;
            N /= 10;
            if (N > 0)
                goto Reverse;
            Console.WriteLine("Reverse  Number  Is  {0}", R);
            Console.Read();
        }
    }
    }


 

 

 

 Output

Enter An Integer : 4567
Reverse  Number  Is  7654




Goto satement in C#, C#.NET, C# goto