sklose / NCalc2

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

Support implicit conversion for primitive-type arguments. #51

Closed fadulalla closed 4 years ago

fadulalla commented 4 years ago

Currently, in order for a method to be found in a lambda context, the arguments must match the parameters exactly.

For example:

public class Context {
   int Sum(double a, double b) => a + b;
}

Sum(1.0, 1.0); // returns 2
Sum(1, 1);      // throws a "method not found" exception, but ideally it should return 2.

Even though an int can be implicitly cast to a double, the method fails. This is similar to issue #37 but deals with primitive types only.