mercredi 23 août 2017

C# - restart a program or end it with Console.ReadKey()

I want the user to decide if he wants to end the programm or start again by clicking on a key (doesn't matter which one). If I do it like this, the user has to double-click on a key to end the program. I would like to know how to write it so the user only has to click once. The problem is: the program starts again if the user writes yes and I would like to keep that.

do
            {
                Console.WriteLine("Nochmal? Gebe \"ja\" ein. Ansonsten auf eine beliebige Taste tippen.");
                again = Console.ReadLine();
                if (again != "ja")

                Console.WriteLine();
                Console.WriteLine();
            }
            while (again == "ja") ;

        Console.ReadKey();

Aucun commentaire:

Enregistrer un commentaire