I need all values to rounded to 8 decimal places. So, for example, 1.2 should round to 1.20000000, but Math.Round(value, 8) rounds to 1.2.

I’m using a C# class to populate and then serialise to xml. One of the values is a double. If I assign a ‘1.2’ to the value this gets serialised to ‘1.2’ when I actually need ‘1.20000000’.

I found this fast way to do this without converting the number to string:

foo = doubleValue + 0.00M;

And that makes the value 1.20000000 instead of just 1.2. This was better then doing a ToString and then parsing it back.

Advertisements