0
1
omoscar muรฑoz
controlarerrores
try { } catch (FormatException Ex) { MessageBox.Show("INTRODUCE NUMEROS."+"\n"+Ex.Message); } catch (OverflowException Ex2) { MessageBox.Show("INTRODUCE UN NUMERO MAS CORTO." + "\n" + Ex2.Message); } catch (Exception Ex) { cadena = "Mensaje: " + Ex.Message + "\n" + "Objeto que causรณ el error: " + Ex.Source + "\n" + "Mรฉtodo que generรณ el error: " + Ex.TargetSite.Name + "\n" + Ex.ToString(); MessageBox.Show(cadena, "Errores"); } finally { if (objeto != null) objeto.
Shortcut: try
try{
num = short.Parse(this..Text);
}
catch (FormatException Ex)
{
MessageBox.Show("INTRODUCE NUMEROS."+"\n"+ Ex.Message);
}
catch (OverflowException Ex2)
{
MessageBox.Show("INTRODUCE UN NUMERO MAS CORTO." + "\n" + Ex2.Message);
}
catch (Exception Ex)
{
cadena = "Mensaje: " + Ex.Message + "\n" +
"Objeto que causรณ el error: " + Ex.Source + "\n" +
"Mรฉtodo que generรณ el error: " + Ex.TargetSite.Name +
"\n" + Ex.ToString();
MessageBox.Show(cadena, "Errores");
}
finally
\\PARA EJECUTAR SI O SI
{
MessageBox.Show("ENTRO");
}