I have this to check digits:
private bool IsDigitsOnly(string str)
{
foreach (char c in str)
{
if (c < '0' || c > '9')
return false;
}
return true;
}
This to check string len
private bool CorrectFormat(string str)
{
if (str.Length == 9)
return true;
return false;
}
I use this on property SET
public string NIF
{
get { return nif; }
set { if (IsDigitsOnly(nif) && CorrectFormat(nif))
nif = value;
}
But when I try to make an object instance I got an error "System null reference exception" when I am using 123456789 in parameter that is always true when checked by two methods before.
Some help?