Round double in two decimal places in C#?

sanjeev40084 picture sanjeev40084 · Mar 1, 2010 · Viewed 406.4k times · Source

I want to round up double value in two decimal places in c# how can i do that?

double inputValue = 48.485;

after round up

inputValue = 48.49;

Related: c# - How do I round a decimal value to 2 decimal places (for output on a page)

Answer

Alex LE picture Alex LE · Mar 1, 2010

This works:

inputValue = Math.Round(inputValue, 2);