[MarshalAs(UnmanagedType.ByValTStr, SizeConst = 10)]
  
*****************************************************************************
欢迎使用CSDN论坛专用阅读器 : CSDN Reader(附全部源代码) 最新版本:20070212http://www.cnblogs.com/feiyun0112/archive/2006/09/20/509783.html

解决方案 »

  1.   

    这样不行啊.
    提示:无法获取托管类型(“stuct.temp”)的变量地址或大小
      

  2.   

    string我也没有试出来
    但是可以work around,可以用char *来替代
     [StructLayout(LayoutKind.Explicit)]
            public unsafe struct temp
            {
                [FieldOffset(0)]
                public int a;
                [FieldOffset(4)]
                public int b;
                [FieldOffset(8)]
                public int c;
                [FieldOffset(12)]            
                public char* str;
            }char*其实就代表string,你以后在new 一下就可以了