DataTable dt = new DataTable();

            String ev_A = 5.88.ToString();
            String ev_B = 2.ToString();
            String ev_C = 4.ToString();
            String ev_W = 10.ToString();

            String expression = "a+(w-b)*c";

            expression = expression.Replace("a", ev_A);
            expression = expression.Replace("b", ev_B);
            expression = expression.Replace("c", ev_C);
            expression = expression.Replace("w", ev_W);


            decimal result=Convert.ToDecimal(dt.Compute(expression,""));

            Console.WriteLine(Math.Round(result,2));
            Console.ReadKey();

  

相关文章:

  • 2021-07-28
  • 2022-12-23
  • 2021-11-20
  • 2021-04-29
  • 2021-10-06
  • 2022-12-23
  • 2022-01-07
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2021-08-03
  • 2021-08-30
  • 2021-12-02
  • 2021-12-23
  • 2022-12-23
  • 2022-01-27
相关资源
相似解决方案