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

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

I want to do this using the Math.Round function

15条回答
  •  不知归路
    2020-11-22 09:53

    Personally I never round anything. Keep it as resolute as possible, since rounding is a bit of a red herring in CS anyway. But you do want to format data for your users, and to that end, I find that string.Format("{0:0.00}", number) is a good approach.

提交回复
热议问题