Dispose as name says,disposes all resources used by the System.IO.Streamreader object.When the streamreader object is disposed then it also closes the underlying stream.
Actually Dispose() is implemented in TextReader class,which is the base class for StreamReader.
using (StreamReader sr = new StreamReader("C:\\rpt.txt"))
file_contents = sr.ReadToEnd();
Asked In: Many Interviews |