Derik Whittaker



Images in this post missing? We recently lost them in a site migration. We're working to restore these as you read this. Should you need an image in an emergency, please contact us at
Don't return in a finally clause – Using .Net
There is a post on DZone today about having a return statement in a finally block. When I first read the code it thought it was odd that this was even allowed.  Not to mention that any sane, rational developer would put a return in a finally block.  I did not really believe the author when he explained the execution path either, so I thought I would give it a try.

I fired up my handy, dandy .Net IDE and threw down some code.  At this point I noticed that .net DOES NOT ALLOW you to put a return (or break) inside a finally block.  In fact you get a message that states ‘Cannot jump out of the finally block’.  I thought this was odd that I got this but the author did not.

It was at this point that I noticed he was coding in Java.  Wow, must suck that a language like Java allows for really shitty practices like allowing a return in a finally block.  I was happy to find out that .net does NOT allow this.

kick it on

Posted 06-29-2007 1:18 PM by Derik Whittaker
Filed under:


About The CodeBetter.Com Blog Network
CodeBetter.Com FAQ

Our Mission

Advertisers should contact Brendan

Google Reader or Homepage Latest Items
Add to My Yahoo!
Subscribe with Bloglines
Subscribe in NewsGator Online
Subscribe with myFeedster
Add to My AOL
Furl Latest Items
Subscribe in Rojo

Member Projects
DimeCasts.Net - Derik Whittaker

Friends of
Red-Gate Tools For SQL and .NET


SmartInspect .NET Logging
NGEDIT: ViEmu and Codekana
NHibernate Profiler
Balsamiq Mockups
JetBrains - ReSharper
Web Sequence Diagrams
Ducksboard<-- NEW Friend!


Site Copyright © 2007 CodeBetter.Com
Content Copyright Individual Bloggers


Community Server (Commercial Edition)