How do I format a number with commas?

ssl picture ssl · Mar 31, 2009 · Viewed 37.6k times · Source
int a = 10000000;
a.ToString();

How do I make the output?

10,000,000

Answer

Christian C. Salvadó picture Christian C. Salvadó · Mar 31, 2009

Try N0 for no decimal part:

string formatted = a.ToString("N0"); // 10,000,000