Generally,
Finalize
has nothing to do with
Dispose
. You never need to call
Finalize
as GC does it, but you need to call
Dispose
for all object implementing this interface. The call to
Close
calls
Dispose(true)
, according to
http://msdn.microsoft.com/en-us/library/system.io.streamreader.close.aspx[
^].
Calling this method is important to free unmanaged resources and especially important for
StreamWriter
(otherwise you can loose the results of writing), so the call should be done in
finally
part of try-finally block:
sreader=new StreamReader("b.txt");
try {
} finally {
sreader.Close();
}
—SA