Warning! Sorry, I'm bad english! Using a fixed array in struct:
[StructLayout(LayoutKind.Explicit, Size = 12)]
public unsafe struct union_reg
{
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 12)]
[FieldOffset(0)]
public fixed byte r[12];
[FieldOffset(0)]
public fixed UInt16 rp[6];
}
try create and get access to elements through array of pointers:
union_reg reg = new union_reg();
byte*[] r = new byte*[9] { ®.r[rB], ®.r[rC], ®.r[rD], ®.r[rE], ®.r[rH], ®.r[rL], &rhl, ®.r[rA], ®.r[6] };
If I declarete it in function, all fine, but if I try declarete it in class, I get error CS1666. Please help solve the problem!
const byte rB = 1;
const byte rC = 0;
const byte rD = 3;
const byte rE = 2;
const byte rH = 5;
const byte rL = 4;
const byte rA = 7;
const byte rF = 6;`