Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 103013
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T01:03:23+00:00 2026-05-11T01:03:23+00:00

I saw this tip in another question and was wondering if someone could explain

  • 0

I saw this tip in another question and was wondering if someone could explain to me how on earth this works?

try { return x; } finally { x = null; } 

I mean, does the finally clause really execute after the return statement? How thread-unsafe is this code? Can you think of any additional hackery that can be done w.r.t. this try-finally hack?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. 2026-05-11T01:03:24+00:00Added an answer on May 11, 2026 at 1:03 am

    No – at the IL level you can’t return from inside an exception-handled block. It essentially stores it in a variable and returns afterwards

    i.e. similar to:

    int tmp; try {   tmp = ... } finally {   ... } return tmp; 

    for example (using reflector):

    static int Test() {     try {         return SomeNumber();     } finally {         Foo();     } } 

    compiles to:

    .method private hidebysig static int32 Test() cil managed {     .maxstack 1     .locals init (         [0] int32 CS$1$0000)     L_0000: call int32 Program::SomeNumber()     L_0005: stloc.0      L_0006: leave.s L_000e     L_0008: call void Program::Foo()     L_000d: endfinally      L_000e: ldloc.0      L_000f: ret      .try L_0000 to L_0008 finally handler L_0008 to L_000e } 

    This basically declares a local variable (CS$1$0000), places the value into the variable (inside the handled block), then after exiting the block loads the variable, then returns it. Reflector renders this as:

    private static int Test() {     int CS$1$0000;     try     {         CS$1$0000 = SomeNumber();     }     finally     {         Foo();     }     return CS$1$0000; } 
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I saw this in an answer to another question , in reference to shortcomings
Saw this post at CodeProject for FCKEditor. Can someone explain what about the new
I saw this in someone's code. What does it mean? def __enter__(self): return self
I saw this question and I am wondering about the same thing in JavaScript.
Saw this in an answer to another question: char (*arrs)[rowSize] = malloc(bytesPerTable); What is
I saw this question and it motivated me to look again (without success) at
Saw this question recently: Given 2 arrays, the 2nd array containing some of the
I saw this question and answer regarding closing img tags. However, what if I
I saw this in a textbook, but the book doesn't explain what it actually
I saw this question: how to save tags(keywords) in database? Good answer for how

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.