dimanche 28 octobre 2018

Going back/forward to a command in C#

        Console.WriteLine('What is your name, traveler?');
        string mainName = Console.ReadLine();
        Console.WriteLine('So, your name is ' + mainName + ' ? y/n');
        char ans = Console.ReadKey;
        if (ans == y) 
        {
            Console.WriteLine('Nice, let me introduce myself now.');
        }
        else if(ans == n)
        {

        }
        else
        {
            Console.WriteLine('Please insert either y or n.');
        }

In the code above, how can I make it so that the else if statement will return to the third line and the else statement will return to the first line of the code and continue running from there?

Aucun commentaire:

Enregistrer un commentaire