Example

using System;
using System.IO;
using System.Text;

namespace Samples
{
  public class TextReaderSample
  {
    public static void Main()
    {
      string s = "textreader.txt";
      using(TextReader tr = new StreamReader(s))
      {
        Console.WriteLine(tr.ReadLine());
        Console.WriteLine((Char)tr.Peek());
        char[] chars = new Char[4];
        tr.Read(chars, 0, chars.Length);
        foreach(char c in chars)
          Console.Write(c);
        Console.WriteLine(tr.ReadToEnd());
      }
    }
  }
}
The output is
Hello world!
G
Goodbye world!

Get .NET Framework Standard Library Annotated Reference, Volume 1: Base Class Library and Extended Numerics Library now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.