Streams
When using streams, it is best to think of the different types of streams in an abstract sense. They are all a stream or a block of data that you can write to or read from. The medium that holds this data differentiates the different stream classes. Therefore, a FileStream hosts a block of data in a file; a MemoryStream hosts a block of data in memory. The methods by which you read from and write to a stream are the same. The following examples will use a FileStream; however, using a MemoryStream or NetworkStream will be, for the most part, identical.
Whereas the streaming classes encapsulate the block of data, one requires readers and writers to read from a stream and to write to a stream, respectively. For a text-based stream, these ...
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