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;
}  

Leave A Reply

Your email address will not be published. Required fields are marked *

You May Also Like

This C# program calculates and displays an upper triangular matrix based on user input. Problem Statement: The program takes the...
This C# program serves as a demonstration of bitwise operators, which are fundamental operators used for manipulating individual bits in...
This C# program is designed to interchange or swap the columns of a matrix. A matrix is a two-dimensional array...