Implements IDisposable in order to achieve a more elegant code
October 30, 2010
know from msdn, using statement is used to call the object Dispose method:
As a rule, when using IDisposable objects should be in the using statement declare and instantiate the object. using statement in the correct way to call the Dispose method on the object, and (as shown in the previous way you use it) will result in the call Dispose the object is outside the scope of their own. In the using block, the object is read-only and can not be modified or re-allocation.
ran into such a situation: by implementing the IDisposable interface Wrapper: The code then becomes: It seems it is more elegant. When you need more processing time, only changes to the wrapper, without the need to make any changes to the calling code, flexibility is better.
Note: This article has nothing to do with IDisposable to release resources.
Posted: January 3rd, 2012
at 2:24pm by admin
Tagged with idisposable
Categories: Uncategorized
Comments: No comments
