This project has moved. For the latest updates, please go here.

Simple expression evaluation

Apr 19, 2015 at 7:58 PM
i tried to evaluate simple code to compute the function with one variable, like this "(x +10.0)/21.0"

here's my code:
public class ExpressionHandler
        public double xx;
        public ExpressionHandler(string func, double x)
            var reg = new TypeRegistry();
            var p = new CompiledExpression<double>() { TypeRegistry = reg };
            p.StringToParse = func;
            xx = p.Eval();
when i launch my function with parameters:
var a = new ExpressionHandler("(x + 10.0)/210.0", 11.0);
i get exception on this line
xx = p.Eval();
the text of exception
{"The binary operator Add is not defined for the types 'System.RuntimeType' and 'System.Double'."}
what am i doing wrong?
Apr 20, 2015 at 5:46 AM

Use RegisterSymbol to register variables. Use RegisterType to register types if you want to call static methods on those types