class Program
    {
       
staticvoid Main(string[] args)
{
           
double d =5.55;

           
// 方法一
            Console.WriteLine(d.ToString("0.0")); // 5.6
            Console.WriteLine(d.ToString("0"));   // 6

           
// 方法二
            Console.WriteLine(Math.Round(d, 1, MidpointRounding.AwayFromZero)); // 5.6
            Console.WriteLine(Math.Round(d, 0, MidpointRounding.AwayFromZero)); // 6

            Console.ReadKey();
        }
    }

相关文章:

  • 2022-12-23
  • 2022-01-23
  • 2022-12-23
  • 2022-12-23
  • 2021-11-20
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2022-01-01
  • 2021-10-17
  • 2022-12-23
  • 2021-11-29
  • 2022-12-23
相关资源
相似解决方案