I can easily specify offset of fields:
[StructLayout(LayoutKind.Explicit)]
public struct MyMarshaled
{
[FieldOffset(0)]
public int Version;
[FieldOffset(3)]
public int SubVersion;
}
but how I can specify field lengths in bit representation? For example like this:
[StructLayout(LayoutKind.Explicit)]
public struct MyMarshaled
{
[FieldOffset(0, lenght=3)]
public int Version;
[FieldOffset(3, length=5)]
public int SubVersion;
}
So, given the byte bitmap 00100001 it will print out struct with value '1' in both fields, i.e 001 is for Version, and 00001 is for SubVersion.