How can I format decimal property to currency?

前端 未结 8 1522
眼角桃花
眼角桃花 2020-12-02 21:50

I want to format a decimal value as a currency value.

How can I do this?

8条回答
  •  情话喂你
    2020-12-02 22:24

    Below would also work, but you cannot put in the getter of a decimal property. The getter of a decimal property can only return a decimal, for which formatting does not apply.

    decimal moneyvalue = 1921.39m; 
    string currencyValue = moneyvalue.ToString("C");
    

提交回复
热议问题