VB.Net- Evaluating Mathematical Expression in a String

|▌冷眼眸甩不掉的悲伤 提交于 2019-11-27 12:32:16

问题


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.


回答1:


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...



来源:https://stackoverflow.com/questions/6604840/vb-net-evaluating-mathematical-expression-in-a-string

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!