这是有效的
public event Func<int,int> createEvents;
但为什么不呢?
public event Action<int> createEvents;
答案 0 :(得分:1)
public event Action<int> CreateEvents;
完全有效。也许您的事件处理方法与Action<T>
代理不匹配。
也许你有这样的事情:
public event Action<int> CreateEvents;
public event Func<int, int> CreateEvents2;
public int OnCreateEvents2(int value)
{
Func<int, int> handler = CreateEvents2;
if (handler != null) return handler(value);
return 0;
}
public void OnCreateEvents(int value)
{
Action<int> handler = CreateEvents;
if (handler != null) handler(value);
}