开发者

Need to print double as 12.20 instead of 12.2

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");

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜