On 02.12.2014 17:18, Michael McGlothlin wrote:
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?

Being part of platform/invoke, Marshal* & friends are not suitable
for byte order conversions because they follow (by design) the
conventions of platform they are working on.


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..

See http://tirania.org/blog/archive/2007/May-15-2.html

Robert


_______________________________________________
Mono-list maillist  -  [email protected]
http://lists.ximian.com/mailman/listinfo/mono-list

Reply via email to