Search code examples
c#numberstostring

How do I format a number with commas?


int a = 10000000;
a.ToString();

How do I make the output?

10,000,000


Solution

  • Try N0 for no decimal part:

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