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 ?
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.
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.
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.
System.IO.Stream stream = new System.IO.MemoryStream();
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With