C# Error CS0748 – Inconsistent lambda parameter usage; parameter types must be all explicit or all implicit

C# Error

CS0748 – Inconsistent lambda parameter usage; parameter types must be all explicit or all implicit

Reason for the Error & Solution

Inconsistent lambda parameter usage; parameter types must be all explicit or all implicit.

If a lambda expression has multiple input parameters, some parameters cannot use implicit typing while others use explicit typing.

To correct this error, either omit all parameter type declarations or explicitly specify the type of all parameters.

Example

The following code generates CS0748, because, in the lambda expression, only alpha is given an explicit type:

class CS0748  
{  
    System.Func<int, int, int> d = (int alpha, beta) => beta / alpha;
}