Rethrow the current exception

To rethrow the current exception, use the throwstatement without passing it an exception.
The following code snippet demonstrates this technique:
try
{
    // Do something dangerous.
}
catch (Exception)
{
    // Log the error.
    // Re-throw the exception.
    throw;
}
Contrast this code with the following version:
try
{
    // Do something dangerous.
}
catch (Exception ex)
{
    // Log the error.
    // Re-throw the exception.
    throw ex;
}

둘의 차이는?

댓글

이 블로그의 인기 게시물

Oracle NLS_DATE_FORMAT 변경

Alternative to IValueConvert, QuickConverter

Reflection with IDispatch-based COM objects