An easy way to do this is:
public boolean isValidFName(string FName, int MinLength = 0)
{
if (FName.Length == 0 || FName.Length < MinLength)
return false;
else
return true;
}
if (isValidFName(txtFName.Text))
{
//Only checks that the first name is not length 0.
}
if (isValidFName(txtFName.Text, 5))
{
//Checks that the first name is at least length of 5.
}
No comments:
Post a Comment