解决方法
因为CLR只能在运行时确定大小…其中一个原因是“填充”(取决于平台)……
For all other types,including structs,the sizeof operator can be
used only in unsafe code blocks. Although you can use the
Marshal.SizeOf method,the value returned by this method is not always
the same as the value returned by sizeof. Marshal.SizeOf returns the
size after the type has been marshaled,whereas sizeof returns the
size as it has been allocated by the common language runtime,
including any padding.
Ref.
另见How do I check the number of bytes consumed by a structure?