Reputation: 3264
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.
Upvotes: 1
Views: 1018
Reputation: 54417
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".
Upvotes: 4