说明: 首先添加引用
1. Microsoft.JScript.Vsa
2. Microsoft.JScript
方法如下:
/// <summary>
/// 计算 字符串表达式
/// </summary>
/// <param name="Formule">字符串计算表达式</param>
/// <returns></returns>
private string CaleByFormule(string Formule)
{
Microsoft.JScript.Vsa.VsaEngine ve = Microsoft.JScript.Vsa.VsaEngine.CreateEngine();
return Microsoft.JScript.Eval.JScriptEvaluate(Formule, ve).ToString();
}