0
How to round a double variable to 0,00?
when i use Math.Round(n, 2) if n is for example 1.20 and i use Console.WriteLine(n) it shows 1.2 is there a way to show it 1.20
2 Answers
+ 2
you need to use string formatter:
double d =1.2;
console.writeline(d.ToString("#.00"));
or:
console.WriteLine("{0:#.00}", d);
both of these print 1.20
0
double d = 1.275;
Math.Round(d, 2); // 1.27
Math.Round((decimal)d, 2); // 1.28