Reputation: 273
I'm trying to convert decimal? price to formatted price. I need such price format:
222,777,333.00
This is my code: String.Format(item.SalePrice.ToString(), "###,###,###.00")
.
Result: 99999.000000
Help, please.
Upvotes: 0
Views: 14698
Reputation: 98810
Using The numeric ("N"
) format specifier in a 2
precision specifier with a culture that has ,
as a NumberGroupSeparator
and .
as a NumberDecimalSeparator
(like InvariantCulture
) is the best way in your case.
item.SalePrice.ToString("N2", CultureInfo.InvariantCulture)
If you don't specify any culture, this method uses CurrentCulture
by default and you might get different representation if your CurrentCulture
has different specifiers for these properties.
Upvotes: 1
Reputation: 408
Try
item.SalePrice.ToString("N");
Check out this msdn article for more options in regards to Decimal.ToString()
.
Upvotes: 1