E
E-John
Guest
Dear all,
Implement union contains array fails, how to fix it?
Thanks and Best regards,
E-John
[StructLayout(LayoutKind.Explicit, Size = 6, Pack = 1)]
public struct UnionArrayStruct
{
[FieldOffset(0)]
public byte[] Bytes;
[FieldOffset(0)]
public UInt16 Offset;
public UnionArrayStruct(int dummyValue)
{
Bytes = new byte[6];
Offset = 0x0000;
}
}
static void Main(string[] args)
{
UnionArrayStruct a = new UnionArrayStruct(0);
a.Bytes[0] = 0x01;
Console.ReadLine();
}
Continue reading...
Implement union contains array fails, how to fix it?
Thanks and Best regards,
E-John
[StructLayout(LayoutKind.Explicit, Size = 6, Pack = 1)]
public struct UnionArrayStruct
{
[FieldOffset(0)]
public byte[] Bytes;
[FieldOffset(0)]
public UInt16 Offset;
public UnionArrayStruct(int dummyValue)
{
Bytes = new byte[6];
Offset = 0x0000;
}
}
static void Main(string[] args)
{
UnionArrayStruct a = new UnionArrayStruct(0);
a.Bytes[0] = 0x01;
Console.ReadLine();
}
Continue reading...