Monday, December 9, 2013

"Using" Statement vs Dispose in C# (.NET: Using using blocks vs. calling .Dispose() )

The using statement ensures that Dispose is called even if an exception occurs while you are calling methods on the object. You can achieve the same result by putting the object inside a try block and then calling Dispose in a finally block; in fact, this is how the using statement is translated by the compiler.

This is described here: http://msdn.microsoft.com/en-us/library/yh598w02.aspx

No comments:

Post a Comment