Best way to define 1D array of double in C# and pass it to and from a C dll.

A

apm

What is the best way to pass an array of double from C# to a win32 dll
written in C? The C code both reads and redefines elements of the array.
Execution speed is also of concern.

Is there anything better than:

double [] x = new double[5000];
fixed(double* X = x)
{
// call dll
unmanageddll(X);
}
 
N

Nicholas Paldino [.NET/C# MVP]

apm

There probably isn't anythinb better than using the unsafe code. If you
don't use the unsafe code, you would have to marshal the values to an
unmanaged block of memory, and then read them back. This is probably the
fastest way you are going to be able to do this.

Hope this helps.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top