C++与C#的数据类型转换

 原文:http://social.msdn.microsoft.com/Forums/zh-CN/visualcshartzhchs/thread/33eb26ff-dbbc-4808-bc53-3719376b4fdd

一维数组的转换例子
C++的是:
struct abc
{
  char aaa[64];
  int bbb;
};  
转换成C#为:
public struct abc
{
  [MarshalAs(UnmanagedType.ByValArray, SizeConst = 64)]
  public byte[] aaa;
  public int bbb;
}

二维数组:

struct GE_DevConfigParaStruct
{
  char phoneActiveCode[4][12];
};

转换成C#为:

GE_DevConfigParaStruct g = new GE_DevConfigParaStruct(new char[4,12]);

//STRUCT
    public struct GE_DevConfigParaStruct
    {

        public char[,] phoneActiveCode;
        public GE_DevConfigParaStruct(char[,] pActiveCode)
        {
            phoneActiveCode = pActiveCode;
        }
    }

你可能感兴趣的:(C++,C#,职场,休闲)