I'm using NCalc to create Mathematical expression in C#:
Expression e = new Expression("2 + 3 * 5");
Debug.Assert(17 == e.Evaluate());
But second line gives me an error - "Operator == cannot be applied to operands of type int and object"
How to solve this problem?
The
Evaluate()
method returns anobject
(from the source code), so you need to insert a cast to make this work:The "simple expressions" example on the NCalc home page is incorrect.