Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

VB.Net- Evaluating Mathematical Expression in a String

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.

like image 353
Walker Avatar asked Jul 07 '11 01:07

Walker


1 Answers

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

like image 128
Reed Copsey Avatar answered Sep 23 '22 03:09

Reed Copsey