Re: try, catch, finally- whats the point of finally?
From: Alan Paulk (apaulk_at_141.com)
Date: 05/04/04
- Next message: cody: "Re: Full Screen"
- Previous message: Jeffrey Tan[MSFT]: "Re: How display RowState in computed column?"
- In reply to: Justin Rogers: "Re: try, catch, finally- whats the point of finally?"
- Next in thread: The Real Andy: "Re: try, catch, finally- whats the point of finally?"
- Reply: The Real Andy: "Re: try, catch, finally- whats the point of finally?"
- Messages sorted by: [ date ] [ thread ]
Date: 4 May 2004 02:54:47 -0700
"Justin Rogers" <Justin@games4dotnet.com> wrote in message news:<emoTLxYMEHA.1348@TK2MSFTNGP10.phx.gbl>...
> 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" <apaulk@141.com> wrote in message
> news:60a93123.0405031922.44bb2db2@posting.google.com...
> > 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
Thanks for the help!
-Alan
- Next message: cody: "Re: Full Screen"
- Previous message: Jeffrey Tan[MSFT]: "Re: How display RowState in computed column?"
- In reply to: Justin Rogers: "Re: try, catch, finally- whats the point of finally?"
- Next in thread: The Real Andy: "Re: try, catch, finally- whats the point of finally?"
- Reply: The Real Andy: "Re: try, catch, finally- whats the point of finally?"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|