帮忙给一条代码,让一个带小数的数字取小数点后两位有效数字就是把45.215745544 变成45.22
然后再把它变成  45.22%
应该是两条代码吧  谢谢了

解决方案 »

  1.   

       double t = 45.215745544;
            double test = Math.Round(t, 2);
      

  2.   

      double t = 45.215745544;
            double test = Math.Round(t, 2,MidpointRounding.AwayFromZero );
      

  3.   

    double x = double.Parse("");
    double y = x % 0.01;
    double z = x - y;
      

  4.   

    Bi = Math.Round((Double.Parse(J.ToString()) / Double.Parse(u.ToString())) * 100);
      

  5.   

    double x = 45.215745544;
    string str = string.Format("{0:0.00}%", x);这是最常用的方法。
      

  6.   

    string one = string.Format("{0:0.00}%", 45.215745544);
    Response.Write(one);