I can't convert byte to stream. Is there an easy way to do that?
Stream stream;
stream = (Stream) vByte; //something is going wrong in this part.
//vByte is a byte variable
I can't convert byte to stream. Is there an easy way to do that?
Stream stream;
stream = (Stream) vByte; //something is going wrong in this part.
//vByte is a byte variable
You need to instantiate a MemoryStream
object with the byte[]
:
MemoryStream stream = new MemoryStream(vByte);
You cannot use cast expressions to convert something to a different type.
Instead, you can create a MemoryStream
around the array.
In general, the cast operator changes the compile-time type of an object to a different type, provided that it actually is an instance of that type at runtime.
For a detailed explanation, see this blog post.