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

  • Thread starter Thread starter sg71.cherub
  • Start date Start date
S

sg71.cherub

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
 
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
 
Back
Top