【发布时间】:2014-12-23 10:52:10
【问题描述】:
我正在使用Mathos Math parser 来评估数学表达式。我正在尝试解析以下表达式,但它抛出 FormatException - 输入字符串格式不正确..
Mathos.Parser.MathParser parser = new Mathos.Parser.MathParser();
string expression = "Math.pow((4),(5))"; //Or "Math.sqrt(1)";
string result = parser.Parse(expression).ToString();
在我的应用程序中,我使用的是 MathDox mathml 编辑器,它提供了 mathml。使用这个mathml,我使用给定here 的javascript 将它解析为普通的数学表达式,然后将此表达式发送到我的c# 代码进行评估。 我的表情有什么问题。
注意:由于某些情况,我不会在 javascript 中评估数学表达式。
【问题讨论】:
-
我喜欢的一个解决方案是在 c# 中使用 javascript eval,使用 Microsoft Jscript 而不是 Mathos。 odetocode.com/articles/80.aspx 但在某些情况下它也会失败
-
能否请您检查我的解决方案是否有效!
标签: javascript c# parsing math evaluation