Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 189
  • Last Modified:

Finally clause

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

Thanks
0
gromul
Asked:
gromul
  • 2
  • 2
1 Solution
 
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
 
Expert1701Commented:
In that case, no.  Neither the try, nor the finally blocks will execute.
0
 
gromulAuthor Commented:
Thanks
0

Featured Post

Receive 1:1 tech help

Solve your biggest tech problems alongside global tech experts with 1:1 help.

  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now