I have this block of code:
try{
this.connection.Open();
cmd.ExecuteScalar();
return true;
}
catch(Exception exc){
throw exc;
}
finally{
this.connection.Close();
}
I know that if the catch
throws the exception, the finally
block will run anyways.
But what about the return in the try
?
If the try
block returns true
, will the finally
block close my connection?
Is this safe?