I'm new to C++/CLI wrapper to C#, I've some issues on passing array to C#.
Native c++
const double *NDimInversion::GetOutputAverage() const
{
if ( mOutputOk )
return mAvgY.data().begin();
else
throw runtime_error("Error in NDimInversion::GetOutputAverage(): output not available.");
}
Native header
const double *GetOutputAverage() const;
Wrapper header
public ref class NDimInversion
public:
array<double>^ GetOutputAverage();
Wrapper c++
array<double>^ NDimInversion::GetOutputAverage() {
array<double> tempArr = nDimInversion->GetOutputAverage(); // ????
const int SIZE = tempArr.size();
array<double>^ tempReturn = gcnew array<double>(SIZE);
for (int i = 0; i < SIZE; i++)
{
tempReturn[i] = tempArr[i];
}
return tempReturn
};
I plan to convert the native return into CLI array, but I couldn't pass the array.
Can you point me what am I missing?
Do I need to carry "const" keyword to CLI as well?