Format currency without rounding

后端 未结 5 476
萌比男神i
萌比男神i 2021-01-15 04:19

I have the need to format a decimal number as currency but I do not wish for any rounding to occur in the process.

For example (example culture is en-US)

<         


        
5条回答
  •  一整个雨季
    2021-01-15 05:07

    ToString("C20") -- C takes a precision suffix

    EDIT: oops, didn't read the question apparently.

    .ToString("C20").Trim('0') seems like the fix, but this doesn't work when you're using string.Format...

提交回复
热议问题