There are two questions actually.
Is it ok to use goto operators, that leads outside try/catch block and what consequences may it lead to?
How can I make this code better?
start:
try
{
oleDbDataAdapter1.Fill(myDataTable);
}
catch (Exception ex) {
DialogResult res = MessageBox.Show("Can't load data:\n" + ex.Message, "Error",
MessageBoxButtons.RetryCancel, MessageBoxIcon.Error);
if (res == DialogResult.Retry)
{
goto start;
}
}
- Is it ok to use
goto
operators, which lead outside atry
/catch
block? What consequences may it lead to? - How can I make this code better?