構造体のアライメントを設定する場合にはStructLayout属性(StructLayoutAttribute)を利用します。
StructLayoutはSystem.Runtime.InteropServices名前空間にあるため、
が必要です。
[StructLayout(LayoutKind.Sequential)]
struct POINT {
public int x;
public int y;
}
[StructLayout(LayoutKind.Explicit)]
struct POINT
{
[FieldOffset(0)]
public int x;
[FieldOffset(4)]
public int y;
}
[StructLayout(LayoutKind.Sequential, Pack=16)]
struct POINT
{
public int x;
public int y;
}
[StructLayout(LayoutKind.Sequential, Pack = 16, Size=64)]
struct POINT3
{
public int x;
public int y;
}