Have you ever tried using the "Using" statement with a method and not a class?
We all have done the following:
1: using(StreamReader s = new StreamReader(@"c:\Test.txt"))
2: {
3: // Do stuff
4: }
Whether you know it or not, the compiler translates that code to the following:
Although the .NET Framework takes the memory management task out of your hands, there are still a few things that you must pay attention to when disposing of an object in order for the Garbage Collector to do its work properly.
You would think that once you remove the reference from an object it will eventually [...]
We pay for user submitted tutorials and articles that we publish. Anyone can send in a contribution
Learn More