C# TextReader Class with Programming Example

In this chapter you will learn:

  • What is TextReader Class and How it Works?
  • Methods of TextReader Class
  • Easy Programming Examples

What is TextReader Class?

TextReader Class represents a reader that can read a sequential series of Characters. It is abstract class that means you cannot instantiate it. After finishing reading or writing file you must dispose or clean memory directly or indirectly. To directly dispose, call Dispose Method in try/catch block and for indirectly disposal write code inside using block.

Programming Examples:

In this programming Example I will open D:\csharpfile.txt using TextReader class, read file and print output on console.

  • Output

    Hello File Handling!
    Hello File Handling!


    In this chapter you learned TextReader class using complete programming example. In the next chapter you will learn BinaryWriter Class in C#.

    Leave a Reply

    Your email address will not be published. Required fields are marked *