我现在是用C#调用C++的一个DLL,参数类型是一个类,
类中有一个字段为vector<pair<string,string>> result,
请问,我在C#中怎么匹配这个C++的类型?

解决方案 »

  1.   

    大致可以有如下对应:
    pair<>     ---        KeyValuePair<>
    vector<>   ---      List<>
      

  2.   

    KeyValuePair<>的链接:
    http://msdn.microsoft.com/zh-cn/library/5tbh8a42%28VS.80%29.aspxList<>的链接:
    http://msdn.microsoft.com/zh-cn/library/6sh2ey19%28v=VS.80%29.aspx他们都属于.NET Framework提供的泛型,请参见:
    http://msdn.microsoft.com/zh-cn/library/0sbxh9x2%28v=VS.80%29.aspx
      

  3.   

    C#调用C++写的DLL?这个涉及Interop,我没有深究,呵呵。不过NET 3.5以后对Interop的支持越来越强大了。建议你先从MSDN入手,看不同语言间的数据类型如何匹配,再上CodeProject之类的网站找点示例程序。
      

  4.   

    vector<pair<string,string>> result
    我做了如下对应都不行啊
    List<KeyValuePair<string, string>> result
    KeyValuePair<string, string>[] result
    Dictionary<string,string>[] result
    List<Hashtable> result
    List<Dictionary<string, string>> result
    string[][,] result
    ArrayList result
    都报:
    尝试读取或写入受保护的内存。这通常指示其他内存已损坏。
    我在网上查了,应该是类型不匹配,等高人
      

  5.   

    应该是不支持c++的集合类。内部的内存结构完全不一样。
    你可用vc写dll中转一下。