I'm trying to write some simple c# code that will validate a username and password, both the username and password are already in the code itself. Moreover, the validation is from a simple username and password - not from any sql database.
If the validation is correct I would like to print (output) - 'correct identification', if the username and/or password is wrong however I would like to output - 'wrong identification'.
My question (as posted by crashmstr) how do I check that the user entered the hard-coded username and password. Which leads to - the OP doesn't seem to know how to check that.
Why is my code outputting 'correct identification', regardless of the input?
            string username = "Pinocchio";
            string password = "Disney";
            Console.WriteLine("Enter Username: ");
            char answer = console.ReadLine()[0];
            Console.WriteLine("Enter Password: ");
            char answer2 = console.ReadLine()[1];
            if (!(username == "Pinocchio" && password == "Disney")) {
                Console.WriteLine("Correct Identification");
            }
            else
            {
                 Console.WriteLine("Wrong Identification");
            }
        }
    }
}
I have this which works... and I can always add a little bit more code later.
string password = "hello";
string username = "how";
if(Console.ReadLine() == password && Console.ReadLine() == username)
{
    Console.WriteLine("Correct Identification");
}
else 
{
    Console.WriteLine("Wrong Identification");
}