Converting from byte arrays to objects
Posted on 2008-11-20
I'm reading a stream of bytes into an application, and need to convert that data to an object. Deserialization is not an option here as the stream does not hold any metadata on the object.
Rather than crafting a method to read the stream into an array of bytes and then allocate each byte by hand to where it should go (assuming I can even do this), is there some magical class I don't know about that can take in a byte array and a Struct, and will do the transformation for me?
Please note...the stream holds data of varying types (ints, longs, strings) - it is not just a text stream unfortunately, so I can't use text decoding.
Many thanks for your help