eyal
eyal

Reputation: 379

how to build Expression<Func<x,y>> with no input parameters?


I use Expression.Call to build MethodCallExpression dynamically. The call is for "First" method. Then, I need to wrap it to Expression<Func<x,y>> (x and y are types, and it irrelevant to the question). I'm trying to do it with Expression.Lambda<Func<x,y>>, but get Incorrect number of parameters supplied for lambda declaration exception when passing
new ParameterExpression[]{} (i.e. empty array) in the ParameterExpression[] input parameter.
what should be provided to Expression.Lambda when the Lambda takes ZERO parameters?

Upvotes: 2

Views: 468

Answers (1)

recursive
recursive

Reputation: 86084

Action is the delegate that corresponds to a void that accepts no parameters. Func<x, y> says that the method accepts an x and returns a y. All the Func delegates return values, and all the Action delegates are void.

Upvotes: 2

Related Questions