0

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. what is the best way to pass the array from C# to C++? (Data structure of this array in C#)
  2. What is the best way to return the array from C++? (Data structure of this array in C++)

My code is not working:

In C#

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

In C++ dll:

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

Thanks for any suggestions; A couple of lines of code will help a lot.

4

1 Answer 1

2

I think it should be:

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

And

DllExportImageStatistics GetImageStats(double pSignalArray[4])
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.