I'm converting code from C++ to C#. I have this line:
typedef bool (*proc)(int*, ...);
Can I do that in C#?
Short answer: Yes.
Generally:
(untested... just an outline)
{
bool AFunction(ref int x, params object[] list)
{
/* Some Body */
}
public delegate bool Proc(ref int x, params object[] list); // Declare the type of the "function pointer" (in C terms)
public Proc my_proc; // Actually make a reference to a function.
my_proc = AFunction; // Assign my_proc to reference your function.
my_proc(ref index, a, b, c); // Actually call it.
}
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments