[Mono-dev] Pass 2D array from C++ to C#

howard.rubin howard.rubin at hl.konicaminolta.us
Wed Mar 15 15:06:49 UTC 2017

So I used mono_array_class_get () to create the class for the 2nd param to
mono_array_new_full (). Then I used mono_array_set() to set the values in
the created array, assuming contiguous array element storage.

    MonoClass* TwoDArrayClass = mono_array_class_get(mono_get_int32_class(),
    uintptr_t lengths[] = { cells.size(), 2 };
    intptr_t lower_bounds[] = { 0, 0 };
    MonoArray* am = mono_array_new_full(domain, TwoDArrayClass, lengths,

    for (unsigned int i=0; i<cells.size(); ++i) {
        mono_array_set(am, int, 2*i, cells[i].first);
        mono_array_set(am, int, 1+2*i, cells[i].second);

View this message in context: http://mono.1490590.n4.nabble.com/Pass-2D-array-from-C-to-C-tp4670248p4670257.html
Sent from the Mono - Dev mailing list archive at Nabble.com.

More information about the Mono-devel-list mailing list