简体   繁体   English

C#将double数组传递给C ++ dll

[英]C# passing double array to C++ dll

I have an array initialized in C# code; 我有一个用C#代码初始化的数组; 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. 然后我将它传递给C ++ dll,其中将使用新值重新分配数组的每个单个条目。 Then the array with be returned back to C# with the new value. 然后使用新值将数组返回给C#。 I am wondering 我想知道

  1. what is the best way to pass the array from C# to C++? 将数组从C#传递给C ++的最佳方法是什么? (Data structure of this array in C#) (C#中此数组的数据结构)
  2. What is the best way to return the array from C++? 从C ++返回数组的最佳方法是什么? (Data structure of this array in C++) (C ++中此数组的数据结构)

My code is not working: 我的代码不起作用:

In C# 在C#中

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

In C++ dll: 在C ++ DLL中:

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

Thanks for any suggestions; 谢谢你的任何建议; A couple of lines of code will help a lot. 几行代码将有很多帮助。

I think it should be: 我认为它应该是:

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

And

DllExportImageStatistics GetImageStats(double pSignalArray[4])

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM