I have a problem with NCalc: I'm trying to implement a way to add an expression to my program by writing it in a textbox and then have the program to use it to sum/multiply variables. Here is an example:
Expression expr = new Expression(textBox3.Text);
expr.Parameters["a"] = 1;
expr.Parameters["b"] = textBox2.Text;
textBox1.Text = expr.Evaluate().ToString();
I want to write the expression in textBox3 and the value of "b" variable in textBox2 and collect the result in textBox1. But if I try, for example, with:
textBox2 = "3"
textBox3 = "b+a"
the result is "31" instead of 4. What's wrong?