I am trying to make a while loop to ensure employee is in correct format - however it works only when I put the employee ID correctly the first time.
When I put first a wrong format to the ID and then put a correct one it does not revaluate and identify it as true
Here is the part of the code in question:
Console.Write("Please enter your employee ID:");
empID = Console.ReadLine();
string pattern = @"^\d{9}[A-Z]{1}$";
Match match = Regex.Match(empID, pattern);
while (match.Success != true)
{
if (match.Success == true)
{
Console.WriteLine(empID);
}
else
{
Console.WriteLine("Incorrect employee ID - please try again");
empID = Console.ReadLine();
}
}
Any idea what it could be that it does not see empID as correct when entered correctly second time?
Thanks