[DllImport("...")]
public static extern IntPtr foo();
Should work. Then if you know the size of the array:
IntPtr result = foo();
double[] arr = new double[10];
Marshal.Copy(result, arr, 0, 10);
If the array size isn't static, then you should return the size of the array like this:
double* foo(int* size) {
double* matrix = (double *)malloc(10 * sizeof(double));
*size = 10;
return matrix;
}
And use:
[DllImport("...")]
public static extern IntPtr foo(out int size);
...
int size;
IntPtr result = foo(out size);
double[] arr = new double[size];
Marshal.Copy(result, arr, 0, size);