I'd like to convert a given float into its binary representation. I tried to write the float value into a MemoryStream, read this MemoryStream byte by byte and convert the bytes into their binary representation. But every attempt failed.
- "Can't read closed stream" (but I only closed the writer)
- For test purposes I simply wrote an integer (I think four bytes in size) and the length of the
MemoryStreamwas 0, when I didn't flush theStreamWriter, and 1, when I did.
I'm sure there is a better way to convert floats to binary, but I also wanted to learn a little bit about the MemoryStream class.