I am learing c# and confused on streams
What are they??
Arey they used to store data or transfer data ??

Pls explain in very simple words

Streams are used to manage sequence of bytes.
Manage: read, write, seek, count.

Sequence of bytes are usually files or images, but can be any data in form of byte array.

Edited 2 Years Ago by AleMonteiro: more info

To me a Stream is like just a bunch of bytes passing by. Hence why they call it a Stream I guess. That bunch of bytes could be just about anything, a signal from an oscilloscope on an USB port, a file downloading from the internet etc. Have a look at the Stream class in MSDN to see what you can do with it.

A stream to me is like everyone says, a collect of bytes. Now, because of this it allows the developer a lot more control of what to do with the data. For instance you could read in an image, or a text file, ext.

Streams can be, well, streamed. You read them in as they come, not having to waiting and load in one whole object all at once (like an image, you can just start pulling the data for the image, not load it in all at once). This means you can allow for a constant flow of data if you want (there are things called streamciphers ... I think I got the name right, that constantly take in data, feeding off the last data to help with the encryption/decrpytion, with really not end specified).

Saying all that, they are faster, I think because you reduce a lot of that background stuff done by .NET (at least initially)

Hope that makes sense, I all of a sudden had trouble finding the right words to type.

This article has been dead for over six months. Start a new discussion instead.