// Program asks user to enter password
// If password is not "home", "lady" or "mouse"
// the user must re-enter the password
//Chapter 4 Debug 1
const string PASS1 = "home";
const string PASS2 = "lady";
const string PASS3 = "mouse";
string password;
Console.Write("Please enter your password ");
password = Console.ReadLine();
while(password != PASS1 || password != PASS2 || password != PASS3)
{
Console.WriteLine("Invalid password. Please enter again. ");
password = Console.ReadLine();
}
Console.WriteLine("Valid password");
Console.ReadKey();
so there is my code, yet another debugging exercise
my problem arrives here
while(password != PASS1 || password != PASS2 || password != PASS3)
I'm not sure what type of bool goes here??
when I replace the != with ==, anything BUT the 3 accepted values returns a "Valid password"
and I'm not totally sure how to fix this error, I got all confused when I went here
http://msdn.microsof...=VS.100%29.aspx
hope that returns the right link/page and not just the default msdn page
thanks in advance for any help
/cheers
This post has been edited by Asji: 14 February 2011 - 10:53 PM

New Topic/Question
Reply




MultiQuote






|