Hi,
I've been reading a bit about the using statement.
ie
My understanding is that this code will call the Dispose() method of w at the end of the using block. None of my previous code has ever included the 'using' block since I just assumed the .NET garbage collector picks everything up and handles all my memory management. Am I wrong? Should I be using the 'using' statement?
I've been reading a bit about the using statement.
ie
Code:
using (TextWriter w = File.CreateText("log.txt"))
{
w.WriteLine("This is line one");
}
My understanding is that this code will call the Dispose() method of w at the end of the using block. None of my previous code has ever included the 'using' block since I just assumed the .NET garbage collector picks everything up and handles all my memory management. Am I wrong? Should I be using the 'using' statement?