T
Thomas
Hello developers,
I have a problem deserializing structures containing numeric data stored in
big endian format using framework Marshal.PtrToStructure() method. There
must be any attribute I can use to specify that MyStruct.Size attribute
(code sample below) is stored as big endian as opposed to default little
endian. I spend two hours gooling and found nothing useful.
I know byte order can be convert in code, but I was wondering if there was
any way of handling it automatically.
Thank you for any pointers.
Thomas
using System.Runtime.InteropServices;
[StructLayout(LayoutKind.Sequential, Pack = 1, CharSet = CharSet.Ansi)]
struct MyStruct
{
[MarshalAs(UnmanagedType.ByValTStr, SizeConst = 20)]
public string Name;
[MarshalAs(UnmanagedType.U4)]
public uint Size;
}
I have a problem deserializing structures containing numeric data stored in
big endian format using framework Marshal.PtrToStructure() method. There
must be any attribute I can use to specify that MyStruct.Size attribute
(code sample below) is stored as big endian as opposed to default little
endian. I spend two hours gooling and found nothing useful.
I know byte order can be convert in code, but I was wondering if there was
any way of handling it automatically.
Thank you for any pointers.
Thomas
using System.Runtime.InteropServices;
[StructLayout(LayoutKind.Sequential, Pack = 1, CharSet = CharSet.Ansi)]
struct MyStruct
{
[MarshalAs(UnmanagedType.ByValTStr, SizeConst = 20)]
public string Name;
[MarshalAs(UnmanagedType.U4)]
public uint Size;
}