What is the use of Close() method of StreamReader class?

 Posted by vishalneeraj-24503 on 1/27/2014 | Category: C# Interview questions | Views: 2083 | Points: 40
Answer:

Close() method releases all the objects which are used by StreamReader object and also closes the StreamReader objects.

string file_contents;

using (StreamReader sr = new StreamReader("C:\\rpt.txt"))
{
file_contents = sr.ReadToEnd();
sr.Close();
}


Asked In: Many Interviews | Alert Moderator 

Comments or Responses

Login to post response