Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

importing a c++ dll into csharp

Status
Not open for further replies.

jmofthenorth

Technical User
May 8, 2007
7
US
Hi,

I was wondering. I'd like to use a function that I have written in c++ in c#. I was planning on doing this using a dll, and have basically gotten that set up, but I was wondering how I should go about addressing the input variables in C#. Specifically, my function looks like this in C++...

extern "C" __declspec(dllexport) double[] _stdcall IntegrateVector(double *y, double segwidth, int *yint){...}[/color red]

where y is a one dimensional double array that the function
and yint is a one dimensional int array, both are modified in the function.

to use this in C# I would use out or ref before the variables ie

IntegrateVector(ref double[] y, double segwidth, ref int[] yint){...}[/color red]

I'm confused as to what I should do in this case because of the language mismatch...

Jesse
 
using ref is okey but if you have not initialized variables before passing them to the function you should use out instead.any way using ref and out both are used to call a function using call by refernce method in c#.

Touraj Ebrahimi
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top