Compiler Error CS0835

Cannot convert lambda to an expression tree whose type argument 'type' is not a delegate type.

If a lambda expression is converted to an expression tree, the expression tree must have a delegate type for its argument. Furthermore, the lambda expression must be convertible to the delegate type.

To correct this error

  • Change the type parameter from int to a delegate type, for example Func<int,int>.


The following example generates CS0835:

// cs0835.cs
using System;
using System.Linq;
using System.Linq.Expressions;

public class C
    public static int Main()
        Expression<int> e = x => x + 1; // CS0835

        // Try the following line instead.
       // Expression<Func<int,int>> e2 = x => x + 1;

        return 1;