Possible duplicate:
C # - How to round a decimal value to two decimal places (for output on a page)
I am trying to display decimal places with four decimal places. DB rounds my number to 4 decimal places, but returns a number with a final 0s (due to the decimal precision of the field), something like 9.45670000. Then when I do this:
string.Format("{0:#,#.####}", decimalValue);
The output I get on the page is 9.4567, which is what I want.
However, if the number returned from the database is 9.45600000, the result after formatting is 9.456
But I need to display 9.4560
How do I format a decimal so that the number of decimal places is always four?
UPDATE: is it possible to use a variable (instead of .0000) if I would like the number of decimal places to be determined dynamically?
source
share