ReSharper
 
Get ReSharper
Get your hands on the new features ahead of the release by joining the Early Access Program for ReSharper 2025.1! Learn more

Code inspection: Redundant lambda expression parameter type specification

Last modified: 08 April 2024

When you instantiate a delegate by using a lambda expression, and pass input parameters to the lambda expression, it might be unnecessary to specify types of those parameters because the compiler can infer them in most cases. For example, if the types accepted by the method were already specified in the delegate declaration, you can omit the types when you specify the method's input parameters.

In the example below, the declared delegate sum is compatible with methods that return an integer value and accept two parameters of the integer type. Therefore, it is safe to remove type specifiers for the parameters x and y, and ReSharper suggests that you do so: