gpt4 book ai didi

c# - 如何在 C# 中创建 "typedef to a function pointer"?

转载 作者:太空狗 更新时间:2023-10-29 23:30:58 25 4
gpt4 key购买 nike

我正在将代码从 C++ 转换为 C#。我有这一行:

typedef bool (*proc)(int*, ...);

我可以用 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.
}

关于c# - 如何在 C# 中创建 "typedef to a function pointer"?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25557262/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com