C# TextWriter
In C# the TextWriter class is written as an abstract class. It is used to create a
sequential series of characters inside a file. It is quite similar to the stream writer
that also allows the user to write sequential characters or text in a file but it doesn’t
require FileStream creation for the operation.
The WriteLine method writes the data inside the file. You can write multiple data
in the file by using multiple WriteLine methods inside the using statement block.
The output will create a text file with the user-defined text.
Output:
C# TextReader
Text reader is another class that is found in System.IO. It is used to read text or any
sequential character from a given file.
In the above program, we have used TextReader to open a file that is kept at a
particular location. Then we declared a string variable to store the data of the file.
The ReadToEnd method ensures that all the data inside the file has been read.
After that, we printed the data to the console.
The output of the above program will be:
The first line with text writer