D
dvestal
I have a class that needs to be serialized to a byte buffer. I'm using
a large, unwieldy, homegrown serialization method, which has to change
every time the class's members change, and I think there's probably a
better way.
I could do the job generically, and in just a few lines, by declaring
the class as [Serializable()], then using a BinaryFormatter to
serialize the object to a memory stream, then getting the buffer from
the memory stream. However, that generates a buffer that's much larger
than the actual size of the members in the class.
Is there an easy way of serializing the object to a byte buffer in a
space-efficient way?
a large, unwieldy, homegrown serialization method, which has to change
every time the class's members change, and I think there's probably a
better way.
I could do the job generically, and in just a few lines, by declaring
the class as [Serializable()], then using a BinaryFormatter to
serialize the object to a memory stream, then getting the buffer from
the memory stream. However, that generates a buffer that's much larger
than the actual size of the members in the class.
Is there an easy way of serializing the object to a byte buffer in a
space-efficient way?