可能重复:
.NET String.Format() to add commas in thousands place for a number格式号
如何在C#中的号码1234567格式化为1,234,567?
可能重复:
.NET String.Format() to add commas in thousands place for a number格式号
如何在C#中的号码1234567格式化为1,234,567?
尝试 的String.Format( “{0:##,####,####}”,8958712551)
用于格式选项Int32.ToString(),参见here或here。
例如:
string s = myIntValue.ToString("#,##0");
相同的格式选项可以是一个的String.Format使用,如在
string s = String.Format("the number {0:#,##0}!", myIntValue);
var decimalValue = 1234567m;
var value = String.Format("{0:N}", decimalValue); // 1,234,567.00
或不美分
var value = String.Format("{0:N0}", decimalValue); // 1,234,567
使用您当前的语言环境的千位分隔符:
int n = 1234567 ;
n.ToString("N0");
或者,对ToString使用重载,它将文化作为参数。
string formatted = string.Format("{0:##,#}", 123456789);
这取决于您的计算机的文化。一些国家使用逗号,一些国家使用点。在我的电脑上,输出是:123.456.789
这个问题已经有足够的答案了,伙计们。你可以停止发布新的。随意删除确切的重复。 – 2011-02-10 08:26:16