Check input which must have special requirements

K

Kil Gore

Guest
I'm supposed to check requirements of a string and if all requirements are there, it should return true if not than false.

The requirements are:

  • It must be 8 characters long
  • It must have one BIG letter
  • It must contain characters from 0 to 9

This is my:

public bool Check(string s)
{
string buchstaben = "QWERTZUIOPÜASDFGHJKLÖÄYXCVBNM";
string ziffern = "0123456789";
foreach (char _c in s)
{
if (ziffern.Contains(_c) && buchstaben.Contains(_c) && s.Length == 8)
{
return true;
}
}
return false;
}


It returns somehow always false.

Continue reading...
 
Top