急!!请问C#怎么调用C++的dll,把字节数组(字节数组byte[]作为形参)传入C++?

weixin_41350689 weixin_41350689 墨衍会员 · AI 创作全网分发 墨衍智能分发 通过墨衍一键同步至各平台 可同步平台 CSDN微信公众号微博知乎掘金百家号博客园抖音小红书 你的文章也可以这样分发 墨衍会员 ¥399起/年,写一次发全网 我也要 + 加入社区
C++:
----------------------------------
extern "C" __declspec(dllexport) int index(char* a);
int __declspec(dllexport) index (char* a)
{
for (int i = 0; i < 10; i++)
{
cout << a[i] << endl;
}
return 0;
}

C#:
--------------------------------------
public void Main(string[] args)
{
[DllImport("DllTest1.dll", EntryPoint = "test")]
public static extern int test(byte[] a);

static void Main(string[] args)
{
byte[] a= new byte[10];
for(int i = 0; i < 10; i++)
{
a[i] = 3;
}
test(a);
}
}
这样字节数组传递不过去,请问C#用的是byte[],C++那边应该用什么类型来接收??
...全文

相关推荐

评论 11
收藏 已收藏
分享
返回顶部
weixin_41350689
C# 111,128 成员 642,536 内容