Showing posts with label decimal control in double value. Show all posts
Showing posts with label decimal control in double value. Show all posts

Wednesday, April 20, 2011

decimal control in double value

There were situation double values are to be controlled only to 3 decimal or 2 decimal.
This one line code does the exact function.
        double d = 42.566454648;
        double d1 = 23.545548125;
        double d2 = d + d1;
        Response.Write(d2.ToString("N3"));