How do I format a number with commas?

Viewed 47740
int a = 10000000;
a.ToString();

How do I make the output?

10,000,000

5 Answers

Try N0 for no decimal part:

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