472,353 Members | 1,271 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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

transfer function pointer (fC/C++) to delegate (C#)

Here I am meeting a problem. I am transfering unmanaged C/C++ codes to
managed C# codes. For the general C/C++ function pointer, it is easy to
implement its function by C# delegate. e.g.

Declare (C/C++): double (* f) (double * x, void * parms);
Declare (C#): public delegate double f (double x, object
parms);

And the ways to use them are logically similiar.

My question is: when the function pointer appears in the function
agument list, how to implement this in C#? e.g.

Declare (C/C++): double (* fdf) (double * x, void * parms, double * f,
double * df);

where: f and df are function pointers, say f is declared as the above
instance.

In this situation, how to implement the cooresponding declaration in
C#, or how can I go over it?

thx to all

Nov 24 '05 #1
2 3329
Hi!

I hope I understand your question correctly.
You simply pass a delegate type argument to the method in C#.

So if you have your f delegate:

public delegate double f (double x, object parms);

And you want your fdf method, you would write:

public double fdf ( double x, f ff, f df );

This would take two delegates of type f as parameter. And there is no
reason you could not write:

public delegate double fdfDelegate ( double x, f ff, f df );

Which would be a delegate, that when called, requires two delegate
arguments.

Hope this helps

-Lenard

sg*********@gmail.com wrote:
Here I am meeting a problem. I am transfering unmanaged C/C++ codes to
managed C# codes. For the general C/C++ function pointer, it is easy to
implement its function by C# delegate. e.g.

Declare (C/C++): double (* f) (double * x, void * parms);
Declare (C#): public delegate double f (double x, object
parms);

And the ways to use them are logically similiar.

My question is: when the function pointer appears in the function
agument list, how to implement this in C#? e.g.

Declare (C/C++): double (* fdf) (double * x, void * parms, double * f,
double * df);

where: f and df are function pointers, say f is declared as the above
instance.

In this situation, how to implement the cooresponding declaration in
C#, or how can I go over it?

thx to all

Nov 24 '05 #2
cool Lenard, it make my concept clear! It works and thank a lot.

Nov 24 '05 #3

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

Similar topics

5
by: ZhangZQ | last post by:
if there is a function in a win32 dll, it is definition is int add(int a, int b); how to define that function pointer in C#? thank you...
2
by: David Rose | last post by:
I have a DLL (not .NET) that takes a function pointer argument and calls that function with an integer argument. The DLL is being called from C#. ...
1
by: edgekaos | last post by:
I want to pass a structure to a unmanaged dll function. Inside this structure there is a pointer to a callback function. Unmanaged code will call...
0
by: Abubakar | last post by:
Hi, I'm making a windows forms app in vs.net 2k3. I added a new "generic c++" (unmanaged class) class to the project which contains some code to...
6
by: Peter Oliphant | last post by:
Here is a simplification of my code. Basically, I have a class (A) that can be constructed using a function pointer to a function that returns a...
10
by: ChrisB | last post by:
Coming from a C/C++ background, how would I pass a function pointer to a function? I want to write a function that handles certain thread spawning....
0
by: Haxan | last post by:
Hi, I have an unmanaged application that converts a function pointer to a delegate and then pass this as a parameter(delegate) to a managed...
10
by: vcquestions | last post by:
Hi. Is there way to have a function pointer to a delegate in c++/cli that would allow me to pass delegates with the same signatures as...
1
by: Kemmylinns12 | last post by:
Blockchain technology has emerged as a transformative force in the business world, offering unprecedented opportunities for innovation and...
0
by: Naresh1 | last post by:
What is WebLogic Admin Training? WebLogic Admin Training is a specialized program designed to equip individuals with the skills and knowledge...
2
by: Matthew3360 | last post by:
Hi, I have a python app that i want to be able to get variables from a php page on my webserver. My python app is on my computer. How would I make it...
0
by: AndyPSV | last post by:
HOW CAN I CREATE AN AI with an .executable file that would suck all files in the folder and on my computerHOW CAN I CREATE AN AI with an .executable...
0
by: Arjunsri | last post by:
I have a Redshift database that I need to use as an import data source. I have configured the DSN connection using the server, port, database, and...
0
hi
by: WisdomUfot | last post by:
It's an interesting question you've got about how Gmail hides the HTTP referrer when a link in an email is clicked. While I don't have the specific...
0
by: Matthew3360 | last post by:
Hi, I have been trying to connect to a local host using php curl. But I am finding it hard to do this. I am doing the curl get request from my web...
0
Oralloy
by: Oralloy | last post by:
Hello Folks, I am trying to hook up a CPU which I designed using SystemC to I/O pins on an FPGA. My problem (spelled failure) is with the...
0
by: Carina712 | last post by:
Setting background colors for Excel documents can help to improve the visual appeal of the document and make it easier to read and understand....

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.