Converting Decimal to string with non-default format

前端 未结 4 1158
醉酒成梦
醉酒成梦 2021-01-07 20:36

I need to convert decimal to string, in this rulers:

120.00 - \"120\"
120.01 - \"120.01\"
120.50 - \"120.50\"
4条回答
  •  不知归路
    2021-01-07 21:18

    Use, decimal.ToString() method. You can specify format with that method if you need:

    decimal d = 120.00;
    string ds = d.ToString("#,#.00#");
    // ds is a formated string of d's value
    

提交回复
热议问题