I have a event handling method like this:
private void btnConfirm_Click(object sender, EventArgs e)
{
//Some code
if (int.TryParse(tboxPhone.Text, out n))
{
korisnik.Phone = n;
command.Parameters.AddWithValue("@phone", korisnik.Phone);
}
else
{
MessageBox.Show("Error. Numerals only!");
return;
}
//Some other code if condition is fulfilled
}
Problem is return not only breaks from method, but entire form. I could live with this, but it is not the best solution. Is there any other way to solve this?
I just saw what’s the problem.
ifstatement was insidetry-catchblock, and when it returns, it goes directly tofinallyblock.I just transfered
Close();fromfinallyblock, and now it works just fine.