[英]How do I make the number “0” display in a textbox?
I have a decimal column that contains percentages. 我有一个包含百分比的小数列。 I'm converting these so that they display as their whole
#
counterparts. 我正在转换它们,以便它们显示为整体
#
对应物。 For example, if a value is 0.35
in the database, I'm displaying it as 35
in the textbox. 例如,如果数据库中的值为
0.35
,则在文本框中将其显示为35
。 However, some of the values are 0.00
, but don't display in the textbox as 0
. 但是,某些值为
0.00
,但不会在文本框中显示为0
。 In fact, nothing shows up at all. 实际上,什么都没有出现。
What would be the proper ToString()
format to use to achieve my desired result? 要达到我想要的结果,正确的
ToString()
格式是什么?
您是否尝试过.ToString("N0")
或我缺少什么?
See the template below: 请参阅下面的模板:
String.Format("{0:0.00}", 123.0);
See http://www.csharp-examples.net/string-format-double/ 参见http://www.csharp-examples.net/string-format-double/
Thus, you multiply by 100 and display without decimal places. 因此,您乘以100并显示不带小数位。 It should work well
应该很好
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.