Finally clause

If there's a return statement outside try/catch/finally block, is finally still executed?

Thanks
gromulAsked:
Who is Participating?
 
Expert1701Connect With a Mentor Commented:
In that case, no.  Neither the try, nor the finally blocks will execute.
0
 
Expert1701Commented:
Yes, in the case of,

  try
  {
    return;
  }
  finally
  {
  }

or,

  try
  {
  }
  finally
  {
  }

  return;

the finally block will be executed.
0
 
gromulAuthor Commented:
What about this?

return;

try
  {
  }
  finally
  {
  }

 
0
 
gromulAuthor Commented:
Thanks
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.