I am fairly new to C#, and feel like this is probably an obvious answer, since I understand what the error means--but I cannot for the life of me see how to fix it! I am getting an "unreachable code detected" warning for my second if statement, so I realize it is not being called, I just don't understand where my error is, or how to go about fixing it. Any help would be greatly appreciated!
The snippet of code I am having the issue with is:
bool valid = true;
if (txtFirst.Text.Length < 1 || txtLast.Text.Length < 1 || txtAddress.Text.Length < 1 || txtCity.Text.Length < 1 || txtState.Text.Length < 1)
{
return false;
}
string usZip = @"^\d{5}$|^\d{5}-\d{4}$";
Regex re = new Regex(usZip);
return re.IsMatch(txtZip.Text);
if (re.IsMatch(txtZip.Text))
return (true);
else
return (false);
return valid;
valid = false;