鉴于以下代码:
void LookupBox_Load(object sender, EventArgs e)
{
Action d = delegate
{
if (!_p.AutoClose)
CloseLookupBox();
};
if (this.ParentForm.MdiParent != null)
this.ParentForm.MdiParent.Deactivate += delegate { d(); };
else
this.ParentForm.Deactivate += delegate { d(); };
}
有没有办法省略委托 { d(); } ?
void LookupBox_Load(object sender, EventArgs e)
{
Action<object,EventArgs> d = delegate
{
if (!_p.AutoClose)
CloseLookupBox();
};
if (this.ParentForm.MdiParent != null)
this.ParentForm.MdiParent.Deactivate += d;
else
this.ParentForm.Deactivate += d;
}
注意:我想内联