I’m reading binary data (either by network stream or from files) that is predefined several years ago. I currently read this data by reading it into a byte array and then convert the array into the fields I need with System.BitConverter. Needless to say this is timeconsuming and error prone.
I wish I could use ISerializable, but I don’t see how this can be implemented for a predefined structure.
I hope for pointers on how to improve my current strategy…
The Marshal interop classes and methods (namely, PtrToStruct and StructToPtr) can help here as well. See: http://msdn.microsoft.com/en-us/library/4ca6d5z7.aspx