为什么 0.ToString("#.##") 返回一个空字符串而不是 0.00 或者至少是 0? [英] Why does 0.ToString("#.##") return an empty string instead of 0.00 or at least 0?
本文介绍了为什么 0.ToString("#.##") 返回一个空字符串而不是 0.00 或者至少是 0?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
为什么 0.ToString("#.##")
返回一个空字符串?不应该是 0.00
或 至少 0 吗?
解决方案
#
在字符串格式中表示该值是可选的.如果您希望获得输出 0.00
,您需要以下内容:
0.ToString("0.00");
请参阅此处了解可传递给此方法的自定义数字格式.>
Why does 0.ToString("#.##")
return an empty string? Shouldn't it be 0.00
or at least 0?
解决方案
#
in the string format indicate that the value is optional. If you wish to get the output 0.00
you need the following:
0.ToString("0.00");
See here for the custom numeric formats that can be passed to this method.
这篇关于为什么 0.ToString("#.##") 返回一个空字符串而不是 0.00 或者至少是 0?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文