Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/309.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/.net/23.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何在visualc+中从C#接收字符串+;基于.NETDLL?_C#_.net_C++_Visual C++_Dll - Fatal编程技术网

如何在visualc+中从C#接收字符串+;基于.NETDLL?

如何在visualc+中从C#接收字符串+;基于.NETDLL?,c#,.net,c++,visual-c++,dll,C#,.net,C++,Visual C++,Dll,如何在基于Visual C++的.net DLL中从C#接收字符串 在C++(使用CLR)中,我有这个代码: #include "stdafx.h" ##include <Windows.h> #include <string> #include <windows.h> namespace NSST { public ref class Wrapper { public: Wrapper() {} static void init

如何在基于Visual C++的.net DLL中从C#接收字符串

在C++(使用CLR)中,我有这个代码:

#include "stdafx.h"
##include <Windows.h>
#include <string>
#include <windows.h>

namespace NSST
{
  public ref class Wrapper
  {
 public:
     Wrapper() {}
    static void init_1(std::string a, std::string b){}
     static void init_2(){}
  };
};
#包括“stdafx.h”
##包括
#包括
#包括
名称空间NSST
{
公共引用类包装器
{
公众:
包装器(){}
静态void init_1(std::string a,std::string b){}
静态void init_2(){}
};
};

但在.NETC中,我只看到一个函数
init\u2
。如何使.net中的
init_1
可见?

您不能使用std::string,应该使用System::string^:

static void init_1(System::String^ a, System::String^ b);

以及如何将System::String ^a转换为std::String a?有可能吗?当然,看看这里:这篇文章的更新链接:(如果旧评论也可以编辑的话,那就太好了)。