怎么把C++中的char**转换成c#里面的string数组

解决方案 »

  1.   

    你要调用C++的dll?
    用System.Text.ASCIIEncoding.ASCII.GetString可以吗?
      

  2.   

    各位大侠能说的明白点吗?
    有没有demo啊?
      

  3.   

            public string[] GetStringArray(IntPtr p/*char** */)
            {
                List<string> retList = new List<string>();
                while (true)
                {
                    IntPtr address = (IntPtr)Marshal.PtrToStructure(p, typeof(IntPtr));
                    if (address == IntPtr.Zero)
                        break;
                    string sz = Marshal.PtrToStringAnsi(address);
                    retList.Add(sz);
                    p = (IntPtr)((Int32)p + 4);
                }
                return retList.ToArray();
            }以上示例以NULL收尾的char**如果定长的,把while (true)改为for(int i=0;i<nLength,i++)即可