exiting consel app by pressing enter twice without inputting data

rejelx

New Member
I wanted to know how can i exit from the application in console by pressing \[code\]Enter\[/code\] twice \[code\]string userInput; // to display back the exact user input if format for the code has been incorrectly entered string morseInput; do { Console.WriteLine("Enter Morse Code: \n"); userInput = Console.ReadLine(); morseInput = userInput.Replace(" ",""); bool isValid = Regex.IsMatch(morseInput, @"^[-.]+$"); // only allow dots and dashes if (isValid) { Console.WriteLine("\nAll permutations:"); var charString = new List<string>(Permutate(morseInput)); foreach (string character in charString) Write(character); } else // Error for improper input format { if (morseInput.Length == 0) Console.WriteLine("Morse can not be zero-length."); else { Console.WriteLine("\nFormat of morse must be only dots and dashes"); Console.WriteLine("Parameter name: " + userInput + "\n"); } } Console.WriteLine("\n"); } while (true);\[/code\]
 
Back
Top