.NET String.Format() to add commas in thousands place for a number

I want to add a comma in the thousands place for a number. 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/8920.html

上一篇: 仿真器如何工作以及它们是如何编写的?

下一篇: .NET String.Format()在数字中为千位添加逗号