我在许多使用 Action 委托(delegate)的在线示例中看到了这一行:
public event Action MyEvent;
但是当我在自己的代码中尝试时,我得到了这个错误
Using the generic type 'System.Action' requires '1' type arguments
文档当然描述了一种没有任何类型参数的 Action 形式。我错过了什么?
最佳答案
扩展安德鲁斯的回答。
在非 3.5 场景中使用 Action 是完全合法的。只需自己定义即可。
public delegate void Action();
关于c# - 具有零参数的 Action 委托(delegate),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/593205/