[Mono-list] Marshaling a struct with network byte order?

Michael McGlothlin mike.mcglothlin at gmail.com
Tue Dec 2 16:18:07 UTC 2014

Is there any common way to correctly marshal a struct such that the resulting bytes are in network byte order? I have a file format that requires this order for compatibility. Currently I'm storing each chunk as a struct and am using Marshal to convert it to/from bytes. Seems to work fine other than being little endian. Is there something like a MarshalAs attribute for controlling byte order?

Couldn't find a general .NET/C# way other than doing it with Array.Reverse() each time. I thought Mono might have dealt with such a cross platform issue itself..

Sent from my iPad

More information about the Mono-list mailing list