O'Reilly logo

C# 5.0 Programmer's Reference by Rod Stephens

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Chapter 18 Streams

What’s in This Chapter

  • Stream, FileStream, and MemoryStream classes
  • Stream readers and writers
  • Opening text files
  • Special stream classes

Wrox.com Downloads for This Chapter

Please note that all the code examples for this chapter are available as a part of this chapter’s code download on the book’s website at www.wrox.com/go/csharp5programmersref on the Download Code tab.

At a basic level, all pieces of data are just collections of bytes. The computer doesn’t actually store invoices, employee records, and recipes. At its most basic level, the computer stores bytes of information. (Or even bits, but the computer naturally groups them in bytes.) It is only when a program interprets those bytes that they acquire a higher-level meaning that is valuable to the user.

Usually it’s not helpful to treat high-level data as undifferentiated bytes, but there are times when it’s useful to ignore the higher-level structure of the data and treat it as just a bunch of bytes.

One important way of thinking about data is the stream, an ordered series of bytes. Files, data flowing across a network, messages moving through a queue, and even the memory in an array can all fit this description.

Defining the abstract idea of a stream lets applications handle these different types of objects uniformly. For example, a cryptographic algorithm can process the bytes in a stream without knowing whether they represent employees, prescription information, or an image.

Visual Studio provides ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required