Resource Initialization (RAII) idioms and try-finally statements form the basis of traditional approaches to writing safe programming exceptions .
My question is: is there something like a Scope Guard Statement in C #?
There is no direct translation of the framework guard idioms embedded in C # or in BCL, but Alex Ronne Petersen wrote a blog post with a solution that uses the IDispoable interface and C # using statements to do something similar to what you are looking for.
IDispoable
using