sklose / NCalc2

expression evaluator for .NET with built-in compiler
MIT License
166 stars 58 forks source link

if function with decimal and double #72

Open vinhent opened 1 year ago

vinhent commented 1 year ago
var expresion = new Expression("if([param1] > 5, [param2], 0.00)");
expresion.Parameters.Add("param1", 5);
expresion.Parameters.Add("param2", 1.5m);

var lambda = expresion.ToLambda<decimal>();
var result = lambda();

I am getting an ArgumentException with the following message: "Argument types do not match". If I change the value of param2 to be a double, it works. My understanding is that 0.00 in this context is interpreted as a double and the 2 arguments of the if function must be of the same type.