【发布时间】:2010-12-20 12:00:38
【问题描述】:
这可能是一个愚蠢的问题,但是我有一种方法可以让页面的语法更易于阅读
public void Do(Delegate method, DispatcherPriority priority = DispatcherPriority.Normal)
{
this.Window.Dispatcher.BeginInvoke(method, DispatcherPriority.Background);
}
那我可以写了
Do(new Action(() =>
{
//DoStuff()
}));
但是,我想将 Action 移到 Do 方法中,这样我就可以写得更简单了:
Do(() =>
{
//DoStuff()
}));
但我有点确定如何编写逆变参数来执行 Do 方法?
【问题讨论】:
标签: c# lambda delegates c#-4.0 contravariance