I am looking for an elegant way, preferably a short linq expression, to count how many alphanumeric characters the specified string contains.
"Bored," I'm doing it now:
int num = 0; for (int i = 0; i < password.Length; i++) { if (!char.IsLetterOrDigit(password, i)) { num++; } } if (num < MinRequiredNonAlphanumericCharacters) return false;
This is already pretty short, but I'm sure that with some linq magic this can be done in an even shorter, equally understandable expression, right?
magnattic
source share