Solve equation like y=0.1*x

Oct 9, 2013 at 2:00 PM
I do have easy equations like y=0.1*x stored as a string. Based on some logic I want to solve for y or for x, depending on which I know.

Ex1: x=5 --> I want to get y=0.5

Ex2: y=2 --> I want to get x=20

Could someone tell me how to use this library to solve this issue?
Oct 22, 2013 at 12:13 AM
Edited Oct 22, 2013 at 12:16 AM
y=0.1*x is not a valid expression

you'll have to write it as 0.1*x and add an x variable

ExpressionContext context = new ExpressionContext();
context.Variables["X"] = 5;

IDynamicExpression e = context.CompileDynamic("0.1*x");