TextReader and TextWriter
The two classes we briefly encountered in the previous examples are subclasses of the TextReader and TextWriter classes. Using object-oriented programming at its best, these base classes offer virtual methods for a series of operations that can be applied in more than just the context of file I/O. In fact, on our much beloved Console class, you can find static properties called In and Out that expose a TextReader and a TextWriter:
string line = Console.In.ReadLine();Console.Out.WriteLine(line);
Console directly offers access to those common operations by providing shortcut methods on the class itself, but in reality a pair of reader and writer objects provides access to the Win32 console. In fact, those readers and writers ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access