Free Trial

Safari Books Online is a digital library providing on-demand subscription access to thousands of learning resources.


  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint

Stream Classes

The .NET Framework classes offer a streams-based I/O framework, with the core classes in the System.IO namespace. All classes that represent streams inherit from the Stream class, and the key classes are listed in Table 11-1.

Table 11-1. Stream Classes in the .NET Framework
Class Description
Stream The abstract base class Stream supports reading and writing bytes.
FileStream In addition to basic Stream behavior, this class supports random access to files through its Seek method and supports both synchronous and asynchronous operation.
MemoryStream A nonbuffered stream whose encapsulated data is directly accessible in memory. This stream has no backing store and might be useful as a temporary buffer.
BufferedStream A stream that adds buffering to another stream, such as a NetworkStream. (FileStream already has buffering internally, and a MemoryStream doesn’t need buffering.) A BufferedStream object can be composed around some types of streams to improve read and write performance.
TextReader The abstract base class for StreamReader and StringReader objects. While the implementations of the abstract Stream class are designed for byte input and output, the implementations of TextReader are designed for Unicode character output.
StreamReader Reads characters from a Stream, using Encoding to convert characters to and from bytes.
StringReader Reads characters from a String. StringReader allows you to treat a String with the same API; thus, your output can be either a Stream in any encoding or a String.
TextWriter The abstract base class for StreamWriter and StringWriter objects. While the implementations of the abstract Stream class are designed for byte input and output, the implementations of TextWriter are designed for Unicode character input.
StreamWriter Writes characters to a Stream, using Encoding to convert characters to bytes.
StringWriter Writes characters to a String. StringWriter allows you to treat a String with the same API; thus, your output can be either a Stream in any encoding or a String.
BinaryReader Reads binary data from a stream.
BinaryWriter Writes binary data to a stream.



  

You are currently reading a PREVIEW of this book.

                                                                                        

Get instant access to over
$1 million worth of books and videos.

  

Start a Free Trial