C# App: Sending jagged arrays to a C++ DLL

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • ShapeMan
    New Member
    • Feb 2008
    • 3

    C# App: Sending jagged arrays to a C++ DLL

    Is it possible to pass a jagged array to a C++ DLL? I've done the following (this is just test code and inside the DLL, all the elements of each array are summed and the sum is returned as a double):

    static extern double AddArrayOfArray (ref double []A, int n, ref int nPts);


    n = 2; //number of arrays in A
    nPts = new int[2] { 2, 3 }; //number of elements in each array
    A = new double[n][];
    A[0] = new double[2] { 1.1, 2.3 };
    A[1] = new double[3] { 1.2, 3.4, 4.5 };

    double Result = AddArrayOfArray (ref A[0], n, ref nPts[0]);

    Within the C++ DLL, only A[0][0] and A[0][1] are being imported, and from A[1][0], things go wrong.

    Is there something I am missing?
Working...