Пример #1
0
        public static string GetYesNoAnswerFromUser(string prompt)
        {
            while (true)
            {
                Console.Clear();
                Factorize.FactorizingMenu();

                Console.Write(prompt + " (Y/N) ");
                string input = Console.ReadLine();

                if (string.IsNullOrEmpty(input) || string.IsNullOrWhiteSpace(input))
                {
                    Console.Clear();
                    Factorize.FactorizingMenu();

                    Console.ForegroundColor = ConsoleColor.Red;
                    Console.WriteLine("Please enter Y/N! ");
                    Console.ResetColor();
                    Console.WriteLine("Press any key to continue. ");
                    Console.ReadKey();
                }
                else
                {
                    if (input.ToUpper() != "Y" && input.ToUpper() != "N")
                    {
                        Console.Clear();
                        Factorize.FactorizingMenu();

                        Console.ForegroundColor = ConsoleColor.Red;
                        Console.WriteLine("Please enter Y/N only. ");
                        Console.ResetColor();
                        Console.WriteLine("Press any key to continue. ");
                        Console.ReadKey();
                        continue;
                    }
                    return(input);
                }
            }
        }
Пример #2
0
 static void Main(string[] args)
 {
     Factorize.Start();
 }