Catch vs Catch (Exception e) y Throw vs Throw e
¿Son estos dos ejemplos de código los mismos?Captura yCaptura (Excepción e) tienen la misma salida, y el resultado también es el mismo si escriboLanzar oTirar e.
Principal:
try
{
A();
//B();
}
catch (Exception e)
{
Console.WriteLine("{0} exception caught.", e);
}
Código 1:
static void A()
{
try
{
int value = 1 / int.Parse("0");
}
catch (Exception e)
{
throw e;
}
}
Código 2:
static void A()
{
// Rethrow syntax.
try
{
int value = 1 / int.Parse("0");
}
catch
{
throw;
}
}