开发者

VB.Net- Evaluating Mathematical Expression in a String

开发者 https://www.devze.com 2023-03-17 16:22 出处:网络
Is there a method that allows me to evaluate a mathematical expression in a string? Example (Not actual Code):

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

开发者_如何学C

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:

  • Simple Math Parser
  • Fast Lightweight Expression Evaluator
  • ILCalc

A search will find many others...

0

精彩评论

暂无评论...
验证码 换一张
取 消