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

Seibar picture Seibar · Sep 19, 2008 · Viewed 744.5k times · Source

I want to add a comma in the thousands place for a number.

String.Format()?

Answer

Seibar picture Seibar · Sep 19, 2008
String.Format("{0:n}", 1234);  // Output: 1,234.00
String.Format("{0:n0}", 9876); // No digits after the decimal point. Output: 9,876