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

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

I want to do this using the Math.Round function

15条回答
  •  不思量自难忘°
    2020-11-22 09:47

    One thing you may want to check is the Rounding Mechanism of Math.Round:

    http://msdn.microsoft.com/en-us/library/system.midpointrounding.aspx

    Other than that, I recommend the Math.Round(inputNumer, numberOfPlaces) approach over the *100/100 one because it's cleaner.

提交回复
热议问题