如何在visualc+中从C#接收字符串+;基于.NETDLL?
如何在基于Visual C++的.net DLL中从C#接收字符串 在C++(使用CLR)中,我有这个代码:如何在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
#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?有可能吗?当然,看看这里:这篇文章的更新链接:(如果旧评论也可以编辑的话,那就太好了)。