Hello All,
I am using the following to format numbers precise to 2 decimal places
with thousand separators:
Double number = 100000.87;
string MyString = String.Format("{0:0,0.00}", number);
// 100,000.87
which is fine.
When the number is less than zero:
Double number = 0.8756;
string MyString = String.Format("{0:0,0.00}", number);
// 00.87
How do output 0.87 instead of 00.87 ?
Thanks in advance.
Alcides - 21 Feb 2008 18:27 GMT
Can try to use String.Format("{0:#,0.00}", number)
The "# " character will do it.
Alcides Schulz
http://alsql.blogspot.com
Claes Bergefall - 22 Feb 2008 10:17 GMT
string MyString = number.ToString("N2");
/claes
> Hello All,
>
[quoted text clipped - 13 lines]
>
> Thanks in advance.
Ben Voigt [C++ MVP] - 22 Feb 2008 23:25 GMT
> Hello All,
>
[quoted text clipped - 13 lines]
>
> Thanks in advance.
Would you mind explaining when 0.8756 became less than zero?