Darnit, sorry, the Ctrl+Enter bug hit again.
Take this code:
try {
// Throw your exception
} finally {
// Run your clean-up here
}
The exception will bubble up the call stack and get caught by
another catch block if one exists, but your finally code will still
get run. If you placed the code outside of the finally block, then
execution would stop at the exception and be thrown up the stack
to be caught. Let's take a resource allocation example.
try {
// My library accesses a stream
// Some error happens and I need to throw an exception for the user.
throw new Exception("Invalid data was in the stream");
} finally {
// Close the stream here
}
--
Justin Rogers
DigiTec Web Consultants, LLC.
Blog:
http://weblogs.asp.net/justin_rogers
"Alan Paulk" <ap****@141.com> wrote in message
news:60**************************@posting.google.c om...
It seems to me if you have a function like this
public void blah()
try
{
blah blah;
}
catch
{
blah de blah;
}
#code that executes whether there is an error or not#
return;
Then the code at the end will execute just as if it were in a finally
block. If that is the case then I don't know what the point of a
finally block is. Couls someone clear that up for me?
-Alan