Re: Pass 2D array from C++ to C#

"howard.rubin" <[email protected]>
Newsgroups gmane.comp.gnome.mono.devel
Message-ID <[email protected]>
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(),
2);
    uintptr_t lengths[] = { cells.size(), 2 };
    intptr_t lower_bounds[] = { 0, 0 };
    MonoArray* am = mono_array_new_full(domain, TwoDArrayClass, lengths,
lower_bounds);

    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.
_______________________________________________
Mono-devel-list mailing list
[email protected]
http://lists.dot.net/mailman/listinfo/mono-devel-list
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.