What is the use of ReadLine() method in StreamReader class.

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

ReadLine is a StreamReader method which returns the next text line from the text file.It reads line one by one from the text file.

For Example:-

string file_contents;

ArrayList arr_list = new ArrayList();

using (StreamReader sr = new StreamReader("C:\\rpt.txt"))
{
while ((file_contents = sr.ReadLine()) != null)
{
arr_list.Add(file_contents);
}
}


Asked In: Many Interviews | Alert Moderator 

Comments or Responses

Login to post response