UI显示时候,需求保留一位小数

        //保留一位小数 参考: http://blog.sina.com.cn/s/blog_620531730100kfz6.html
        float ff = 1.01f;
        //1.
        string baseValue = ff.ToString("0.#");
        Console.WriteLine(baseValue);
        //2.
        Console.WriteLine(Math.Round(ff, 1));
        //3.默认为保留1位
        string str1 = String.Format("{0:F1}", ff);

 

相关文章:

  • 2021-05-31
  • 2022-12-23
  • 2022-12-23
  • 2021-12-11
  • 2022-02-08
猜你喜欢
  • 2022-02-27
  • 2021-08-11
  • 2022-12-23
  • 2022-12-23
  • 2021-12-18
  • 2022-12-23
  • 2022-02-19
相关资源
相似解决方案