问题描述
在下面的例子中,逗号是小数点分隔符
In the example below, comma is the decimal separator.
我有这样的:125456,89
I have this : 125456,89
我想有这样的:125.456,89;其它为例:23456789,89 => 23.456.789,89
I'd like have this : 125.456,89; other exemple : 23456789,89 => 23.456.789,89
谢谢,
推荐答案
通常格式化数字作为货币,你应该使用C格式说明:
Usually to format a number as a currency, you should use the "c" format specifier:
string formatted = price.ToString("c");
这将使用当前线程的默认区域性确定格式化规则,但是可以明确,如果指定它你想
That will use the current thread's default culture to determine the formatting rules, but you can specify it explicitly if you want.
如果没有帮助,请给我们更多的信息,并阅读这两个页面:
If that doesn't help, please give us more information and read these two pages:
- Standard numeric format strings
- Custom numeric format strings
编辑:从您的评论,这听起来像你的或者的要指定一个明确的定义数字格式字符串的或的建立你自己的的NumberFormatInfo
对象(这只是一个克隆现有相继设置属性的物质),并传递到一个格式化的呼叫。
From your comment, it sounds like you either want to specify an explicit custom numeric format string, or build your own NumberFormatInfo
object (which is just a matter of setting properties after cloning an existing one) and pass that into a formatting call.
这篇关于格式化货币的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!