Is it possible to declare struct array field in another struct?
[StructLayout(LayoutKind.Sequential, Pack = 1)]
public unsafe struct A
{
}
[StructLayout(LayoutKind.Sequential, Pack = 1)]
public unsafe struct B
{
public fixed A FieldA[123];
}
Visual Studio tells that FieldA can only be an array of any simple type not a struct. Is there any solution/workaround here?
Yes, but there are restrictions if you want to make it a fixed-size buffer. From section 18.7.1 of the C# 4 spec:
I don’t know of any alternatives to emulate fixed sized buffers of arbitrary structs.