Hacker News new | past | comments | ask | show | jobs | submit login

Elaborating a bit on kenjackson's reply, the code in a finally block is guaranteed to run after the code in the try block, which is the whole point of finally. A use block unrolls into a try/finally block where the finally cleans up the resource declared in the use initializer.

I'm not sure about try/catch without the finally, perhaps there is some error check that occurs in the IL after the body of the try block?




In MSIL, there's actually no such thing as a try/catch/finally -- only try/catch, try/finally (and the lesser-known try/fault and try/filter). When you write a try/catch/finally in C#, the compiler generates a try/catch inside of a try/finally.




Consider applying for YC's Spring batch! Applications are open till Feb 11.

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: