I've been trying to figure out how to get my console to close when someone finally types the wrong answer (in my quiz)?
I've tried Environment.Exit(); but it doesn't work... It gives me the error: "no overload for method 'Exit' takes 0 arguments.
Here's a bit of my code. I've marked with a comment where I'd want the quit code to be:
Console.WriteLine("In what country was Adolf Hitler born?");
string userAnswer = Console.ReadLine();
if (Answers.AnswerOne.Equals(userAnswer))
{
Console.WriteLine("Congratulations! {0} is the correct answer!", Answers.AnswerOne);
Console.WriteLine("\n\n(Press Enter to move on to the next question...)");
}
else if (!Answers.AnswerOne.Equals(userAnswer))
{
Console.WriteLine("Sorry! You wrote the wrong answer!\nThe correct answer was {0}.", Answers.AnswerOne);
Console.WriteLine("\n\n(Press Enter to exit...)");
Console.ReadKey();
//EXIT CONSOLE
}
Otherwise, the code runs perfectly fine.
Thanks in advance.