I want the user to only be able to proceed if their username's last 3 characters are digits. How would you code that? Any help would be appreciated!
My current code but it doesn't work:
static bool checkUsername(string user)
{
//bool containsAtLeastThreeDigits = user.Any(char.IsDigit);
var counter = user.Count(x => Char.IsDigit(x));
bool valid = false;
int count = 0;
if (counter == 3)
{
count++;
}
else
{
Console.WriteLine("Password must have 3 digits");
}
if (count == 1)
{
valid = true;
}
return valid;
}