On Sun, 31 Aug 2008 08:54:33 -0700, Andrus <ko********@hot.eewrote:
[...]
>The custom numeric format "0.00" is one custom format string that is
essentially equivalent to "F".
0.00 shows always 2 places after comma
F format shows as many places after comma as decimal contains.
No, it doesn't. If you don't specify a precision, it uses the current
culture's NumberFormatInfo.NumberDecimalDigits property. All you have to
do to match the behavior as "F" is to use the same number of digits in
your custom format as the NumberDecimalDigits property indicates.
On my installation (culture of US English), the default precision is 2,
and that's how many decimal places "F" shows, even if there are no
significant digits to the right of the decimal.
[...]
>Use a valid custom numeric format string that correctly describes your
desired output, instead of the character 'f' or 'F'. It being a custom
numeric format, you can use whatever you like, as long as it's valid.
But you might want to start with "0.00".
0.00 shows always 2 places after comma.
For the US English culture, so does "F". Your own culture settings might
be different. But "F" does not take into account the number itself when
deciding how many places to show.
I want custom format which is same as F
Then just write a format like "0.00", except with as many decimal digits
as is appropraite for the culture you're using. If you want to do this
dynamically, you could use something like this:
int cdigitDecimal =
CultureInfo.CurrentCulture.NumberFormat.NumberDeci malDigits;
string strDecimalFormat = "{1:0." +
new String('0', cdigitDecimal) + "}";
Then just use that string wherever you need it (for example, in building
the custom format string that handles zero the way you want).
Pete