Input and Output Classes


This is the lecture about classes for input and output in C#. The most fundamental of these are class Stream and its subclasses. In addition to the Stream classes, C# also supports a number of so-called Reader and Writer classes. These classes are built on (delegate to) a stream, but they do not inherit from a stream. We discuss Text and Binary readers and writers. We also look at string readers and string writers. In addition, we will study the classes that allows us to represent files and directories as objects. Text/char encoding, the Console class, and C# attributes are also touched on. We devote a part of this lecture to a study of serialization, which is a simple and easy means to obtain persist objects. The lecture is finalized with a discussion of the Decorator design pattern, which is relevant for building one stream on top of another stream.

Table of contents