Geeks With Blogs
Title Of Blog

I was asked this question today and was unable to give a truly correct answer which bothered me. So, using this handle tool called the "internet" I quickly found an oldie but goodie that filled me in www.codeproject.com/KB/cs/tinguusingstatement.aspx

I've seen people make use of the "using" keyword in samples I've found online in the past but never took the time to figure out why. I always presumed it was shorthand for referencing a particular objects properties & methods without having to go line by line. Turns out this keyword prevents you from necessarily having to write a try/catch/finally block in order to dispose of the object/resource when finished.

In hindsight I really should have looked this up sooner. For the longest time I've added try/catch/finally blocks sometimes specifically so that I could dispose of certain resources when finished (i.e. I/O, database, etc.).

In the words of the late Chris Farley in Black Sheep..."boy do i feel like a horse's patoot!"

Posted on Monday, October 3, 2011 6:41 PM C# | Back to top


Comments on this post: What's that "using" keyword used for again???

No comments posted yet.
Your comment:
 (will show your gravatar)


Copyright © Jake Rutherford | Powered by: GeeksWithBlogs.net