如何在基于 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(){}
};
};
但在 .net C# 中,我只看到一个函数 init_2
。如何使 init_1
在 .net 中可见?
最佳答案
你不能使用 std::string,你应该使用 System::String^:
static void init_1(System::String^ a, System::String^ b);
关于c# - 如何在基于 Visual-C++ 的 .net DLL 中从 C# 接收字符串?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3539230/