What is the use of StreamReader in C#?

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

StreamReader is a class used in Dot Net to read Text files.As name suggests it reads data from a byte stream.Actually it implements a System.IO.TextReader that reads characters from a byte stream in a particular encoding.

We have to give a proper file path in its constructor otherwise it will give FileNotFound error.

Syntax:-
StreamReader sr = new StreamReader("path of the file");


Asked In: Many Interviews | Alert Moderator 

Comments or Responses

Login to post response