Apr 14, 2014 at 4:15 AM
Edited Apr 14, 2014 at 4:16 AM

How to resolve exponents? If I try 3^5, I get 6? Why?
var expression = new CompiledExpression("3^5");
txtResult.Text = expression.Eval().ToString();


Developer
Apr 17, 2014 at 3:03 AM

Hi,
I'm not sure if you are coming from a VB background, where ^ means exponent.
In C# the ^ operator is in fact the XOR operator, and 3 XOR 5 = 6.
In C#, the usual way to get the exponent is through the Math.Pow function.
Add a reference to the Math class using TypeRegistry, then use Math.Pow(3, 5)

