Reputation: 51
Hi there when I type yes or no/No it doesnt do what Its supposed to do what am I doing wrong?
class Program
{
static void Main(string[] args)
{
Console.WriteLine("Username:");
String user = Console.ReadLine();
Console.WriteLine("Password:");
String Pass = Console.ReadLine();
Console.WriteLine("Are You Sure Your User: " + user + " And Pass: " + Pass + " is correct? Yes/No");
Console.ReadLine();
if (Console.ReadLine() == "Yes" || Console.ReadLine() == "yes")
{
Console.WriteLine("You May now close this");
}
else if(Console.ReadLine() == "No" || Console.ReadLine() == "no")
{
Console.WriteLine("Pleas Press enter");
System.Diagnostics.Process.Start(Environment.GetCommandLineArgs()[0], Environment.GetCommandLineArgs().Length > 1 ? string.Join(" ", Environment.GetCommandLineArgs().Skip(1)) : null);
}
}
}
Upvotes: 0
Views: 287
Reputation: 1007
You are asking for user input twice. The first Console.ReadLine();
is what you are typing "Yes" or "No" into, however your if
/else if
statements are asking for input again.
Console.WriteLine("Are You Sure Your User: " + user + " And Pass: " + Pass + " is correct? Yes/No");
var input = Console.ReadLine();
if (input == "Yes" || input == "yes")
{
Console.WriteLine("You May now close this");
}
else if(input == "No" || input == "no")
{
Console.WriteLine("Pleas Press enter");
System.Diagnostics.Process.Start(Environment.GetCommandLineArgs()[0], Environment.GetCommandLineArgs().Length > 1 ? string.Join(" ", Environment.GetCommandLineArgs().Skip(1)) : null);
}
Upvotes: 6