Friday, 1 September 2017

How to Use Goto Statements C# With Example

How to Use Goto Statements C# With Example

C# Goto Statement Example

    using System; 
    public class GotoExample 
        { 
          public static void Main(string[] args) 
          { 
          ineligible: 
              Console.WriteLine("You are not eligible to vote!"); 
     
          Console.WriteLine("Enter your age:\n"); 
          int age = Convert.ToInt32(Console.ReadLine()); 
          if (age < 18){ 
                  goto ineligible; 
          } 
          else 
          { 
                  Console.WriteLine("You are eligible to vote!");  
          } 
          } 
       } 

Post a Comment

Whatsapp Button works on Mobile Device only

Start typing and press Enter to search