C#传递双阵列到C ++ DLL [英] C# passing double array to C++ dll

查看:248
本文介绍了C#传递双阵列到C ++ DLL的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个在C#代码中初始化的数组;然后我将把它传递给C ++ DLL,其中数组的每个单个条目将重新分配新的值。然后将数组返回到带有新值的C#。
我想知道

I have an array initialized in C# code; Then I am going to pass it to C++ dll in which each single entry of the array will be re-assigned with new value. Then the array with be returned back to C# with the new value. I am wondering


  1. 将数组从C#传递到C ++的最好方法是什么? (C#中此数组的数据结构)

  2. 从C ++返回数组的最佳方法是什么? (C ++中此数组的数据结构)

我的代码无效:

在C#

private static double[] _statsArray = new double[4];
GetImageStats( ref _statsArray);

在C ++ dll中:

In C++ dll:

DllExportImageStatistics GetImageStats( double (&pSignalArray)[4])

任何建议;

推荐答案

我认为应该是:

private static double[] _statsArray = new double[4];
GetImageStats(_statsArray); // Lose the ref

DllExportImageStatistics GetImageStats(double pSignalArray[4])

这篇关于C#传递双阵列到C ++ DLL的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆