动态表达式字符串计算公式

  string ruhufugailv = "0";

string formulaSet = "A/(A+B+C)*100";

string formulaSet01 = formulaSet;

formulaSet01 = formulaSet01.Replace("A", "" + (decimal)normalcounttotal + "").Replace("B", "" + (decimal)misscounttotal + "").Replace("C", "" + (decimal)rejectcounttotal + "");
ruhufugailvtotal = Convert.ToDecimal(new System.Data.DataTable().Compute(formulaSet01, "")).ToString("0.0");

原文地址:https://www.cnblogs.com/llsade/p/11841275.html