Shan
Shan

Reputation: 2832

How to format a string with 1000s separator and zeros after comma in C#

I want to format a string with 1000's separator and also two decimal places by default

I tried this one but it's not working as it fails to append two zeros when there are no decimals

String.Format("{0:#,##0.##}", money); //I want something like 1000.23 and also 1000.00

Upvotes: 0

Views: 431

Answers (1)

fubo
fubo

Reputation: 45947

Just to be sure you're not making this more complicated then necessary

String.Format("{0:f2}", money);

Maybe standard number format is enough and custom number format is not needed. But as mentioned if your Culture has a , as seperator, this won't work.

Upvotes: 2

Related Questions