I need to format numbers (using WPF converters), and the only way I can do it is via string.Format.
I have two formatting parameters: scale and precision. I can achieve what I need separately, but it doesn't work with both:
Example (that works):
string.Format("{0:#,##0,,}", 1234567890.123m) == "1,235"
string.Format("{0:#,#.000}", 1234567890.123m) == "1,234,567,890.123"
What I need:
string.Format("????", 1234567890.123m) == "1,234.568"
(which would mean 1,234.568 Millions) As you can see I can't find a format pattern that would both scale and also display decimals.
Any idea?
A colleague of mine got the solution:
string.Format("{0:#,##0,,.000}", 1234567890.123m) == "1,234.568"
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With