我正在将代码从C++转换为C#.我有这条线:
typedef bool (*proc)(int*, ...);
Run Code Online (Sandbox Code Playgroud)
我可以用C#做到吗?
简短回答: 是的。
一般来说:(
未经测试......只是一个轮廓)
{
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.
}
Run Code Online (Sandbox Code Playgroud)