I'm trying to create a procedure whereby the user must enter a password, if it's wrong, they can try again. After a total of 3 tries the user logs off. I don't need help with the logging off part, but instead, I need help creating the looped part so the user has 3 tries before the log off is executed. I've tried using a do loop and IF statements but for the life of me I just can't seem to figure it out.
This is the code I have got so far, but, as you can see, it's not working, and I know I have messed it up, I just can't seem to figure the problem out.
int count = 0;
do
{
if (PwordInput.text == "Password")
{
Application.Exit();
}
else
{
Console.Beep(2000, 500);
PwordInput.Clear();
count = count + 1;
}
} while (count < 3);
if (count == 3)
{
//Log off code
}
I know the answer will be something simple (maybe using the wrong sort of loop?), but I just can't seem to figure it out, like I said, I'm new to C#, thanks

New Topic/Question
Reply



MultiQuote





|