BDInfo.runner.GetYorNdefaultY C# (CSharp) Method

GetYorNdefaultY() static private method

static private GetYorNdefaultY ( ) : bool
return bool
        static bool GetYorNdefaultY()
        {
            ConsoleKey response;

            do
            {
                while (Console.KeyAvailable) // Flushes the input queue.
                    Console.ReadKey();

                Console.Write("Y/n? ");
                response = Console.ReadKey().Key;
                Console.WriteLine(); // Breaks the line.
            } while (response != ConsoleKey.Y && response != ConsoleKey.N && response != ConsoleKey.Enter);

            /*
             * Return true if the user responded with 'Y/Enter', otherwise false.
             *
             * We know the response was either 'Y/Enter' or 'N', so we can assume
             * the response is 'N' if it is not 'Y/Enter'.
             */
            return (response == ConsoleKey.Y || response == ConsoleKey.Enter);
        }