Your score says 1234567. It should say 1,234,567.

C# can format it right inside the string.

Your score says 1234567. It should say 1,234,567.

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.

FormatValueResult
N012345671,234,567
F112.345612.3
P00.7575%
D37007

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}