回答編集履歴

1

LayoutKind.Explicit に変更

2022/05/07 08:05

投稿

KOZ6.0
KOZ6.0

スコア2668

test CHANGED
@@ -8,18 +8,18 @@
8
8
  public byte[] timestamp;
9
9
  }
10
10
 
11
- [StructLayoutAttribute(LayoutKind.Sequential, Pack = 1)]
11
+ [StructLayoutAttribute(LayoutKind.Explicit)]
12
12
  public struct EthPacket1
13
13
  {
14
- public EthPacket eth;
14
+ [FieldOffset(0)] public EthPacket eth;
15
- public RawPoint raw;
15
+ [FieldOffset(9)] public RawPoint raw;
16
16
  }
17
17
 
18
- [StructLayoutAttribute(LayoutKind.Sequential, Pack = 1)]
18
+ [StructLayoutAttribute(LayoutKind.Explicit)]
19
19
  public struct EthPacket2
20
20
  {
21
- public EthPacket eth;
21
+ [FieldOffset(0)] public EthPacket eth;
22
- public SpherPoint spher;
22
+ [FieldOffset(9)] public SpherPoint spher;
23
23
  }
24
24
 
25
25
  [StructLayoutAttribute(LayoutKind.Sequential)]