C# can format it right inside the string.

The problem
Glued strings, raw numbers.
var text = "Score: " + score + " Time: " + time;// Score: 1234567 Time: 12.3456789
Hard to read in code, and the numbers come out exactly as stored.
The fix
Put the values inside the string.
Start the string with $ and drop values in curly braces. Add a colon to format them.
{score:N0}→1,234,567
The fix in code
One readable line.
var text = $"Score: {score:N0} Time: {time:F1}s";// Score: 1,234,567 Time: 12.3s
N0 adds separators with no decimals. F1 keeps one decimal place.
Cheat sheet
The formats you'll use most.
| Format | Value | Result |
|---|---|---|
| N0 | 1234567 | 1,234,567 |
| F1 | 12.3456 | 12.3 |
| P0 | 0.75 | 75% |
| D3 | 7 | 007 |
Formats follow the player's language settings, so N0 shows 1.234.567 in Germany.
The rule
Let the string do the formatting.
- Thousands
- {n:N0}
- Decimals
- {n:F1}
- Percent
- {n:P0}