Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to create an instance of System.IO.Stream stream

Tags:

c#

stream

memory

How to create an instance of System.IO.Stream stream. One of my function receives System.IO.Stream stream as parameter and write some thing to it. So how can I create a new instance of the same and pass it to the function ?

like image 963
Rauf Avatar asked Nov 04 '11 05:11

Rauf


People also ask

What is System IO stream?

Stream: System. IO. Stream is an abstract class that provides standard methods to transfer bytes (read, write, etc.) to the source. It is like a wrapper class to transfer bytes. Classes that need to read/write bytes from a particular source must implement the Stream class.

What is MemoryStream in C# with example?

The MemoryStream class creates streams that have memory as a backing store instead of a disk or a network connection. MemoryStream encapsulates data stored as an unsigned byte array that is initialized upon creation of a MemoryStream object, or the array can be created as empty.

How do streams work in C#?

In C# file operations, normally streams are used to read and write to files. A stream is an additional layer created between an application and a file. The stream is used to ensure smooth read and write operations to the file. Streams are normally used when reading data from large files.


1 Answers

System.IO.Stream stream = new System.IO.MemoryStream(); 
like image 54
Rauf Avatar answered Oct 17 '22 21:10

Rauf