string表达式运算

方法一:
引用using Microsoft.JScript.dll
然后使用Eval.JScriptEvaluate方法
具体如下:
string result = string.Format("({0}-{1})/100",500,100);
Console.WriteLine(Microsoft.JScript.Eval.JScriptEvaluate(result, Microsoft.JScript.Vsa.VsaEngine.CreateEngine()).ToString());

方法二:
str_value = new DataTable().Compute(string.Format(tbCount_Rules.Text.Trim(), ListToObject(percount)), "").ToString();

原文地址:https://www.cnblogs.com/flish/p/2093662.html