double s = 12.20;
Console.开发者_运维问答WriteLine(s);
It prints 12.2
but I need it to print 12.20
. How can I do this?
You can specify the format for converting a number to a string - here's one way of many. Google ".net numeric format strings" for more...
Console.WriteLine(s.ToString("0.00"));
quoting this
Console.WriteLine(value.ToString("F")); // Displays -16325.00
try s.ToString("0.00");
精彩评论