0% found this document useful (0 votes)
31 views2 pages

Streams in C#

Uploaded by

ragini4651
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
31 views2 pages

Streams in C#

Uploaded by

ragini4651
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

Streams in C#

Streams in C# allow you to carry data from one point to another quickly and
efficiently. The data transfer can take place between files, sockets, objects, or even
other streams.

Streams in CLR come in three forms: streams that read and write bytes, streams
that read and write characters, and a stream to read and write primitive types.
Table 1 lists the types of streams.

Table 1: Streams in .NET

Byte Streams in C#
Byte streams comprise classes that treat data in the stream as bytes. These
streams are most useful when you work with data that is not in a format readable
by humans.

Stream Class
In the CLR, the Stream class provides the base for other byte stream classes. If you
want to implement your own byte-stream class, you have to override the Stream
class, which is an abstract class. Table 2 highlights some of the properties of a
stream.

Table 2: Some Important Properties of a Stream

The Stream class provides support for both synchronous and asynchronous
reading and writing of data through the methods outlined in Table 3.
Table 3: Some Methods for Asynchronous Reads and Writes

Table 4 lists other methods you can use with the Stream class. Note that you should
always call the Close method explicitly rather than depend upon the Garbage
Collector (GC) to free any resources used by the stream.

Table 4: Other Useful Methods


Conclusion
This would have helped you in understanding Streams and Byte Streams in C#.

You might also like