public static void Main()
Console.WriteLine(Eval("15 * (3 + 5) / (7 - 2)"));
public static string Eval(string expr)
var temp = new System.Data.DataTable();
result = $"{temp.Compute(expr, string.Empty)}";
catch (System.Data.EvaluateException ex)
if (ex.Message.ToLower().Contains("cannot find column"))
throw new System.Data.SyntaxErrorException($"Syntax error: Invalid expression: '{expr}'."
+ " Variables as operands are not supported.");