Is it true that if i use the following, it will take less resources and the cleanup will be faster?
using (TextReader readLogs = File.OpenText("C:\\FlashAuto\\Temp\\log.txt"))
{
//my stuff
}
as compared to:
TextReader readLogs = new StreamReader("C:\\FlashAuto\\Temp\\log.txt");
//my stuff
readLogs.Close();
readLogs.Dispose();
The difference between those examples isn’t performance, but exception safety.
usingcreates atry...finallyblock in the background.For reference type the disposing happens via:
From ECMA-344 C# Language Specification 4th Edition
You also don’t need to call both
CloseandDispose. Those functions are equivalent.