How to round a decimal for output?

后端 未结 5 593
醉梦人生
醉梦人生 2020-12-10 10:19

Using C#, I want to format a decimal to only display two decimal places and then I will take that decimal and subtract it to another decimal. I would like to be able to do t

5条回答
  •  夕颜
    夕颜 (楼主)
    2020-12-10 10:34

    You can use: Math.Round(number,2); to round a number to two decimal places.

    See this specific overload of Math.Round for examples.

提交回复
热议问题