TypeName | RemoveDelegateParenthesisWhenPossible |
CheckId | SA1410 |
Category | Maintainability Rules |
Cause
A call to a C# anonymous method does not contain any method parameters, yet the statement still includes parenthesis.
Rule Description
When an anonymous method does not contain any method parameters, the parenthesis around the parameters are optional.
A violation of this rule occurs when the parenthesis are present on an anonymous method call which takes no method parameters. For example:
this.Method(delegate() { return 2; });
The parenthesis are unnecessary and should be removed:
this.Method(delegate { return 2; });
How to Fix Violations
Remove the unnecessary parenthesis after the delegate keyword.