Quantcast
Channel: Answers for "How important is it to wrap temp variables/objects in a "using" block?"
Viewing all articles
Browse latest Browse all 8

Answer by Dave Carlile

$
0
0
Any object you create that references limited, external, non-managed resources - files likely being the most common - should be created with *using* to make sure those resources are released as soon as possible. http://msdn.microsoft.com/en-us/library/yh598w02(v=vs.100).aspx It also makes sure that if any sort of exception occurs while using the resource that it is properly released. Think of it as an "acquire-use-release" sort of pattern for resources.

Viewing all articles
Browse latest Browse all 8

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>