分类：电脑/网络-程序设计
问题：c#问题structtagSLD_MsgHead{publicC 
                  strt tagSLD_MsgHead    {      public Char[] lable;//数据包标识     };    private void MyForm_Load(object sender, EventArgs e)    {      tagSLD_MsgHead Msghead = new tagSLD_MsgHead();      Msghead.lable = new char[] { };      byte[] bytes = new byte                  strt tagSLD_MsgHead    {      public Char[] lable;//数据包标识     };    private void MyForm_Load(object sender, EventArgs e)    {      tagSLD_MsgHead Msghead = new tagSLD_MsgHead();      Msghead.lable = new char[] { };      byte[] bytes = new byte[Marshal.SizeOf(Msghead)];      IntPtr structPtr = Marshal.AllocHGlobal(Marshal.SizeOf(Msghead));      Marshal.StructureToPtr(Msghead, structPtr, false);      }谁能告诉我为什么报char数组类型不匹配的错
回答：应该在 结构  struct tagSLD_MsgHead
里面加上 下面这句，定义结构的大小

[MarshalAs(UnmanagedType.ByValArray, SizeConst = 20)]