How to evaluate a mathematical expression in Unity's C#

Is there an javascript-like Evaluate() function in C# or any other similar method?

I have a simple mathematical expression (no brackets, only -, +, / and * operands) stored in a string and I want to be able to evaluate that and get the result in a float.

Example: For the input string "2+3-5*7" the output should be -30.

I tried to implement a method myself, but I have troubles converting a character to an int. It seems like I get the ASCII code of the character in my int instead of the value I want.

I found what I was looking for here: http://www.logiclabz.com/c/evaluate-function-in-c-net-as-eval-function-in-javascript.aspx

The method that works in Unity is:

public static double Evaluate(string expression)  
{  
    return (double)new System.Xml.XPath.XPathDocument  
    (new System.IO.StringReader("< r />")).CreateNavigator().Evaluate  
    (string.Format("number({0})", new  
    System.Text.RegularExpressions.Regex(@"([\+\-\*])").Replace(expression, " ${1} ").Replace("/", " div ").Replace("%", " mod ")));  
}

Some more info here:

http://stackoverflow.com/questions/4629/c-eval-equivalent

This one does the trick.