The way I understand your question:
- You want a thousand separator every 3 digits on the integer side
- You want 1 digit on the fractional side
Additionally, I would guess that
- You want at least 1 digit on the integer side
The problem with the format strings you're using is that you're using #
to specify digit positions. According to the documentation, this character means:
Replaces the "#" symbol with the corresponding digit if one is present; otherwise, no digit appears in the result string.
(my emphasis)
on the other hand, the 0
character:
Replaces the zero with the corresponding digit if one is present; otherwise, zero appears in the result string.
(again, my emphasis)
So you should use some 0
's instead of #
's.
Specifically, here is the format string I would use according to the 3 bulletpoints at the top of this answer:
#,##0.0
This means:
- comma means "add a thousand separator"
- The
#,##0
thus means "set aside place for the integer part here, add the thousand separator if necessary, and only add digits after the first if necessary, but always add at least one digit, so that you don't get just .1
as a result"
.0
means "1 fractional digit"
- Your
.#
mean "add the decimal point and the fractional digit if the fractional digit is other than 0, if it is 0, don't add either", so that's probably the main problem with your formatting strings
Here's a .NET Fiddle to try it with.