Marshal.StructureToPtr fails with bool and fixed size array?

后端 未结 2 1684
闹比i
闹比i 2021-01-02 09:43

If I marshal this struct with StructureToPtr and then unmarshal it again with PtrToStructure, my first node has y = {1,2} whilst my second node has

2条回答
  •  时光取名叫无心
    2021-01-02 10:24

    You should also pack the struct or class before you use it. That works for me, almost as good as memcpy

    [StructLayout(LayoutKind.Sequential, Pack = 1)]
    public class SomeClass
    {
    }
    

提交回复
热议问题