interviews.dotnetthread.com

↑ Grab this Headline Animator

Monday, October 13, 2008

using Statement in C#

> Provides a convenient syntax that ensures the correct use of IDisposable.
> The using statement calls the Dispose method on the object in the correct way, and (when you use it as shown earlier) it also causes the object itself to go out of scope as soon as Dispose is called. Within the using block, the object is read-only and cannot be modified or reassigned.
> The using statement ensures that Dispose is called even if an exception occurs while you are calling methods on the object like Try/Finally block.
> Dispose method is used to explicitly release unmanaged resources in conjunction with the garbage collector. The consumer of an object can call this method when the object is no longer needed.

Submit this story to DotNetKicks

No comments:

Post a Comment

Post your comments/questions/feedback for this Article.

 

Latest Articles