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

标签 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_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/

相关文章:

c# - Linq 查询获取对象列表并为每个对象获取另一个嵌套列表

c# - 属性 : get property name 的自定义 JsonConverter

c# - 如何让 Linq to SQL 识别动态存储过程的结果集?

.net - 如何衡量在 NGen 之前正确地重新设置 .NET 程序集的效果?

c# - 如何修改 web 服务代理以获取原始 XML

c++ - 从函数返回 istream 的正确方法

c++ - DLL 项目中的静态链接函数

c# - 我如何使用 linq 附加到每个项目的 stringbuilder

c# - Realm 数据库异步查询和.Net

c++ - 从 Python 脚本控制 C++ 输出