.NET String.Format()在数字中为千位添加逗号
我想为数字在千位上添加一个逗号。 String.Format()
?
String.Format("{0:n}", 1234); //Output: 1,234.00
string.Format("{0:n0}", 9876); // no digits after the decimal point. Output: 9,876
我发现这是最简单的方法:
myInteger.ToString("N0")
int number = 1000000000;
string whatYouWant = number.ToString("#,##0");
//You get: 1,000,000,000
链接地址: http://www.djcxy.com/p/8919.html
上一篇: .NET String.Format() to add commas in thousands place for a number
下一篇: How to escape braces (curly brackets) in a format string in .NET