Monday, 27 May 2013

Resource Disposal

try
{
    // Code here that might throw an exception...

    if (arbitraryCondition)
    {
        return true;
    }

    // Code here that might throw an exception...
}
catch (Exception ex)
{
    throw ex;

finally
{
    // Code here gets executed regardless of whether "return true;" was called 
    within the try block (i.e. regardless of the value of arbitraryCondition).
}

1 comment: