Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
有没有一种方法可以让我评估字符串中的数学表达式?示例(不是实际代码):
输入 = "2+2"
输出 = SomeMethod(输入)
输出 = 4
更新:没关系,我通过使用 DataTable.Compute 找到了解决方法。
您需要一个数学表达式解析器来处理这个问题。
以下是 CodePlex 上的一些各种开源选项:
搜索会发现许多其他...