Given the code below:
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(); };
}
Is there a way to omit the delegate { 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;
}
Note: I want to do this inline