Question

Could some one help me to find a good way to round decimal monetary values to nearest multiples of 10 cents/pennies

10.47 is 10.50

10.4366677 is 10.40

10.489999 is 10.50

I have my money value stored in a decimal variable.

Was it helpful?

Solution

Math.Round and Decimal.Round both let you specify a number of decimal places to round to. If you then want to display the value with two decimal places then you need to call ToString and specify that by using a format specifier like "c2", "n2" or "f2".

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top