Im creating a little practice commend line application that has to ask for passwords.This is a section of the code that is suppose to run if the user puts spaces in a password.
It works fine up to that point but then no matter what the user inputs it always passes to the else stament and exits.
Heres that part of the code:
if (hasSpace == true) //Checks for spaces and asks to rewrite if true
{
Console.WriteLine("Your password may not contain spaces, would you like to try again (Y,N)");
ConsoleKeyInfo input = Console.ReadKey();
if (input.Key == ConsoleKey.Y)//Dosnt work
{
runagain = true;
}
if (input.Key == ConsoleKey.N)//Dosnt Work
{
Environment.Exit(0);
}
else
{
Environment.Exit(0);
}
}
I know theres probbably a very simple solution to this but nothing ive tried as worked so far.