Code inspection: Anonymous method signature is not necessary
This inspection reports an anonymous method signature when the parameter list is not needed and can be omitted. That usually means the delegate target type already provides the signature and the anonymous method does not rely on syntax that requires explicitly declaring parameters.
using System;
class C
{
void M()
{
EventHandler handler = delegate(object sender, EventArgs args) { };
}
}
using System;
class C
{
void M()
{
EventHandler handler = delegate { };
}
}
This inspection does not report cases where removing the signature would change semantics or lose required modifiers.
13 April 2026