VB.Net-评估字符串中的数学表达式 [英] VB.Net- Evaluating Mathematical Expression in a String

查看:185
本文介绍了VB.Net-评估字符串中的数学表达式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有没有一种方法可以让我评估字符串中的数学表达式?示例(不实际代码):



输入=2 + 2



输出= SomeMethod



输出= 4



更新:Nevermind,我通过使用DataTable.Compute找到了一种方法。 / p>

解决方案

您需要一个数学表达式解析器才能处理此问题。



以下是CodePlex上的各种开源选项:





搜索会发现很多其他...


Is there a method that allows me to evaluate a mathematical expression in a string? Example (Not actual Code):

Input = "2+2"

Output = SomeMethod(Input)

Output = 4

Update: Nevermind, I found a way around it by using DataTable.Compute.

解决方案

You'll need a math expression parser to handle this.

Here are some various open source options on CodePlex:

A search will find many others...

这篇关于VB.Net-评估字符串中的数学表达式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆