I’m sending some packets of data across the network and they arrive in byte[]s, lets say the structure is
[int, int, byte, int]
If this was c++ I would declare a struct* and point to the byte[]. I’m doing this project in c# and I’m not sure whether it is worth it with marshalling overhead, or if there is a better way to handle it in c#, I’m all ears.
- update, for clarity
Basically, what he is doing
Marshaling a Byte array to a C# structure
Except I’m wondering if it is worth it.
I think marshaling is the best option. You could parse the byte array by yourself using BitConverter, but that would require more work on your part and is not as flexible.