If valid password is entered output is:- "Invalid password. Please enter again."
Please advise me the error in this program?
// Program asks user to enter password
// If password is not "home", "lady" or "mouse"
// the user must re-enter the password
using System;
public class DebugFive2
{
public static void Main()
{
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");
}
}
Loading

Sukesh MarlaRank #461 · 5.4K reputationPosted Aug 11, 2012, 9:25 PM EDT
This is the right way of doing..
Hope It Helped. Please Mark answer as Accepted Answer.
bagzli36 reputationPosted Aug 11, 2012, 5:22 PM EDT
Example
while(pass1.Equals(password) || pass2.Equals(password) || pass3.Equals(password))
{
//bad pass enter again
}
//correct pass
bagzli36 reputationPosted Aug 11, 2012, 9:58 PM EDT
Sukesh MarlaRank #461 · 5.4K reputationPosted Aug 11, 2012, 10:00 PM EDT
Please Check This is correct answer. bagzli :) if it helped
Posted Aug 11, 2012, 10:04 PM EDT
Sukesh MarlaRank #461 · 5.4K reputationPosted Aug 11, 2012, 10:05 PM EDT