Source: Stack Overflow
http://stackoverflow.com/questions/6395305/c-dll-interop-with-c-exposing-multidimensional-arrays-of-unknown-size-and-m
C#:
[DllImport(<dllPath>, CallingConvention = CallingConvention.Cdecl)]
static extern void ChangeArray2d(double[,] arr, int l1, int l2);
//populated with some sample values
double[,] arr = new double[,] { { 1, 2, 3, 4 }, { 5, 6, 7, 8 } };
ChangeArray2d(arr, arr.GetLength(0), arr.GetLength(1));
C++:
__declspec(dllexport) void ChangeArray2d( double* arrayin, int height, int width)
{
for (int n = 0; n<height; n++){
for (int m = 0; m<width; m++){
arrayin[n*width+m] = arrayin[n*width+m] + 100;
}
};
return;
}