How do you round a number to two decimal places in C#?

后端 未结 15 1318
挽巷
挽巷 2020-11-22 08:59

I want to do this using the Math.Round function

15条回答
  •  暖寄归人
    2020-11-22 09:44

      public double RoundDown(double number, int decimalPlaces)
            {
                return Math.Floor(number * Math.Pow(10, decimalPlaces)) / Math.Pow(10, decimalPlaces);
            }
    

提交回复
热议问题