Is there a string math evaluator in .NET?

前端 未结 16 1710
长情又很酷
长情又很酷 2020-11-22 01:01

If I have a string with a valid math expression such as:

String s = \"1 + 2 * 7\";

Is there a built in library/function in .NET that will p

16条回答
  •  日久生厌
    2020-11-22 01:42

    For anybody developing in C# on Silverlight here's a pretty neat trick that I've just discovered that allows evaluation of an expression by calling out to the Javascript engine:

    double result = (double) HtmlPage.Window.Eval("15 + 35");
    

提交回复
热议问题