Possible Duplicate:
Converting string expression to Integer Value using C#
I'm just wondering if there are any built-in functions in C# / .NET in order to parse and evaluate mathematical expressions at run-time.
Our users should be able to write expressions into a text file, like
bmi = weight / (height * height)
and the program should then be able to calculate these formulas
For our expressions, we need at least these capabilities:
- Basic arithmetic operations + - * /
- Brackets
- Functions for calculating square roots and natural logarithms, like sqrt(), ln()
- Use of pre-defined variables. Variables will be filled in by our program, and the user should then be able to calculate with them.
If there is no such thing in .NET, is there a library you could recommend?
Well, I would be able to write an expression parser myself - I know all the theory about it, this was even one of the greatest things at university :-) - but still, it just feels like re-inventing the wheel.