I'm using this code to validate a email address that the user types in a text box. The code works but the only problem is if the user types a valid email than delets it I get an error saying that the address parameter can't be null. It is not going to the catch part on an error. Why?
private bool checkMailLL(string mail)
{
try
{
var test = new MailAddress(mail);
return true; //valid email
}
catch (FormatException ex)
{
return false; //invalid email
}
}