C
Cody Powell
Greetings all,
I'm wondering if there's a rule of thumb related to objects that
implement IDisposable, but whose Dispose() methods are actually marked
as protected. If you dig around System.IO, you'll see a lot of these,
like StreamReader, StreamWriter, etc. Is it still a best practice to
wrap those objects in a using block?
All of the MSDN docs DO wrap such objects in a using block, but I'm
wondering if that actually accomplishes anything. Also, does anyone
know why the Dispose method is marked as protected on such objects?
Thanks for any insight you can provide,
Cody
I'm wondering if there's a rule of thumb related to objects that
implement IDisposable, but whose Dispose() methods are actually marked
as protected. If you dig around System.IO, you'll see a lot of these,
like StreamReader, StreamWriter, etc. Is it still a best practice to
wrap those objects in a using block?
All of the MSDN docs DO wrap such objects in a using block, but I'm
wondering if that actually accomplishes anything. Also, does anyone
know why the Dispose method is marked as protected on such objects?
Thanks for any insight you can provide,
Cody