C#中的字符串格式为货币 [英] String format in C# to currency

查看:258
本文介绍了C#中的字符串格式为货币的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述





我想格式化一个负号,说-12345到货币。



代码:

String.Format({0:c}, - 12345);



结果:

($ 12,345.00)



但我需要以下格式



$ -12,345.00



如何编码?

Hi,

I would like to format a negative number say -12345 to currency.

Code:
String.Format("{0:c}", -12345);

Result:
($12,345.00)

But I need in the following format

$-12,345.00

How do I code this?

推荐答案

12,345.00)



但我需要以下格式


12,345.00)

But I need in the following format


-12,345.00



如何对此进行编码?
-12,345.00

How do I code this?


您好,

如果你谷歌,你可以在这里找到解决方案:

< a href =http://stackoverflow.com/questions/1001114/string-format0c2-1234-currency-format-treats-negative-numbers-as-posi> http://stackoverflow.com/questions/1001114/string -format0c2-1234-currency-format-treats-negative-numbers-as-posi [ ^ ]

祝你好运。
Hi,
If you google, you can find the solution here:
http://stackoverflow.com/questions/1001114/string-format0c2-1234-currency-format-treats-negative-numbers-as-posi[^]
Best regards.


这篇关于C#中的字符串格式为货币的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆