Creating Dynamic Func <> dynamically - Lambdas vs. trees Expression

Here is some code to return a linear function (y = ax + b).

public static Func<double, double> LinearFunc(double slope, double offset)
{
    return d => d * slope + offset;
}

I could do the same with expression trees, but I'm not sure if it is worth the effort.

I know that lambda will capture parameters, which is a drawback. Are there any other pros and cons that I don't know about?

My main question is: is it worth using expression trees in this scenario? Why or why not?

+5
source share
1 answer

, -. , ( ), - , , , .

, :

  • , . LINQ

, .

+5

All Articles