boolean - Bool statement in a while loop c# -


for code, had goto start; statement repeat section until valid name entered, teacher not goto had change it.

currently got i'm not sure why not working. begin program wont start cuz later in code use input username , not recognize when use in bool statement. purpose of testing removed username line later on , program opens skips bool statement.

please me make work. thanks

bool namevalidation = true; while (namevalidation == false) {     console.write("enter name: ");  // asks name     username = console.readline();      if (regex.ismatch(username, @"^[a-za-z- ]+$"))  // validates input containts characters and/or spaces     {         namevalidation = true;                   }     else  // error message if input not valid     {         console.clear();  // clear screen         console.writeline("please enter valid name.");         namevalidation = false;     } } 

set nameavalidation = false

bool namevalidation = false; while (namevalidation == false) { console.write("enter name: ");  // asks name username = console.readline();  if (regex.ismatch(username, @"^[a-za-z- ]+$"))  // validates input containts characters and/or spaces  {     namevalidation = true;                } else  // error message if input not valid  {     console.clear();  // clear screen     console.writeline("please enter valid name.");     namevalidation = false;   } } 

Comments

Popular posts from this blog

Redirect to a HTTPS version using .htaccess -

Unlimited choices in BASH case statement -

javascript - jQuery: Add class depending on URL in the best way -