(使用.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);
}
我想把委托存储在一个通用的集合中,以便稍后可以将其取出来调用。如何正确地进行类型转换?