Solved

Finally clause

Posted on 2006-06-14
4
178 Views
Last Modified: 2010-04-16
If there's a return statement outside try/catch/finally block, is finally still executed?

Thanks
0
Comment
Question by:gromul
  • 2
  • 2
4 Comments
 
LVL 11

Expert Comment

by:Expert1701
ID: 16906956
Yes, in the case of,

  try
  {
    return;
  }
  finally
  {
  }

or,

  try
  {
  }
  finally
  {
  }

  return;

the finally block will be executed.
0
 

Author Comment

by:gromul
ID: 16907964
What about this?

return;

try
  {
  }
  finally
  {
  }

 
0
 
LVL 11

Accepted Solution

by:
Expert1701 earned 500 total points
ID: 16908106
In that case, no.  Neither the try, nor the finally blocks will execute.
0
 

Author Comment

by:gromul
ID: 16908150
Thanks
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Introduction This article series is supposed to shed some light on the use of IDisposable and objects that inherit from it. In essence, a more apt title for this article would be: using (IDisposable) {}. I’m just not sure how many people would ge…
Performance in games development is paramount: every microsecond counts to be able to do everything in less than 33ms (aiming at 16ms). C# foreach statement is one of the worst performance killers, and here I explain why.
Established in 1997, Technology Architects has become one of the most reputable technology solutions companies in the country. TA have been providing businesses with cost effective state-of-the-art solutions and unparalleled service that is designed…

829 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question