How to get byte array from custom object without saving to file

I would like to store data from custom class arrays to webserver. I was hoping to do this using binary. I’ve been able to send bytes to my webserver fine. The issue is how to I serialize and deserialize to a byte array directly. The only thing I can find on this topic is people storing files on the users computer using the standard binaryformatter and FileStream with no intention to send to a webserver.

Use the memory stream rather than the file stream. Take a look at this:


https://stackoverflow.com/questions/1446547/how-to-convert-an-object-to-a-byte-array-in-c-sharp