如何将string格式的数字转换成1位小数的浮点数
如“10.5”转换成10.5

解决方案 »

  1.   

    float f = float.Parse("10.5");
      

  2.   


    string s = "333.33333";
    s = float.Parse(s).ToString("0.0");
    float d = float.Parse(s);//d=333.3
      

  3.   

    float f = float.Parse("10.5");
      

  4.   

    应该这样:
    string s = "333.33333";
    float f = (float)System.Math.Round(double.Parse(s), 1);
      

  5.   

    Convert.ToDouble("10.5");就着么点事
      

  6.   

    decimal co=Convert.ToDecimal("");
    co=Math.Round(co,1);
      

  7.   


    string x = "10.5";
    float Float = float.Parse(x);
    Console.WriteLine("{0:f1}", Float);
      

  8.   

    float.Parse(substring(x,x.indexof('.')+1))