Reputation: 199
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?
Upvotes: 1
Views: 2661
Reputation: 82944
The Evaluate()
method returns an object
(from the source code), so you need to insert a cast to make this work:
Debug.Assert(17 == (int) e.Evaluate());
The "simple expressions" example on the NCalc home page is incorrect.
Upvotes: 2