snippetcsharpCritical
.NET String.Format() to add commas in thousands place for a number
Viewed 0 times
netforaddcommasnumberformatstringplacethousands
Problem
I want to add a comma in the thousands place for a number.
Would
Would
String.Format() be the correct path to take? What format would I use?Solution
$"{1234:n}"; // Output: 1,234.00
$"{9876:n0}"; // No digits after the decimal point. Output: 9,876Code Snippets
$"{1234:n}"; // Output: 1,234.00
$"{9876:n0}"; // No digits after the decimal point. Output: 9,876Context
Stack Overflow Q#105770, score: 1569
Revisions (0)
No revisions yet.