(使用.NET 4.0)好的,我有
private Dictionary<int, Action<IMyInterface, IMyInterface>> handler {get; set;}
public void Foo<T, U>(Action<T, U> myAction)
where T : IMyInterface
where U : IMyInterface
{
// | This line Fails
// V
Action<IMyInterface, IMyInterface> anotherAction = myAction;
handler.Add(someInt, anotherAction);
}
Run Code Online (Sandbox Code Playgroud)
我正在尝试将委托存储在一个泛型集合中,所以我可以稍后将其拉回来调用它.我该如何正确施展它?