473,386 Members | 1,706 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

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

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);
}
Nov 17 '05 #1
1 1509
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.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"apm" <Co*********@AdsorptionProcessModeling.com> wrote in message
news:NdCVe.7463$nq.2776@lakeread05...
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);
}

Nov 17 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: Kyler Laird | last post by:
I'm trying to do some georeferencing - using points of known location (ground control points, GCPs) on an image to develop a polynomial that can be used to approximate the locations of other...
10
by: nospam | last post by:
Hello! I can pass a "pointer to a double" to a function that accepts double*, like this: int func(double* var) { *var=1.0; ... }
7
by: bowlderster | last post by:
Hello,all. I want to get the array size in a function, and the array is an argument of the function. I try the following code. /*************************************** */ #include<stdio.h>...
10
by: Tammy | last post by:
Hello all, I am wondering what is the best way to declare a struct to be used in other c and c++ files. Such as for a C API that will be used by others. 1. Declaring the typedef and the...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.