So I have a function inside of a C++ library:
double MyFunc(double** data, int length)
{
//data elements are accessed like this
(*data)[i] = 5.0;
}
In C# I access this function in this way:
//import
[DllImport(@"MYDLL.dll")]
public static extern double MyFunc(ref double[] data, int length);
//usage
MyFunc(ref data, data.Length);
This is silly since I would rather write:
double MyFunc(double* data, int length)
{
//data elements are accessed like this
data[i] = 5.0;
}
The problem is, I do not know how I could access the desired C++ function from C#…I am not well versed in Marshaling values…How would I do this?
You can simply pass a
double[]directly.