I need to display float as
我需要将float显示为
1.00
1.50
1.55
1.60
The following is what I see using f2 format.
以下是我使用f2格式看到的内容。
1.
1.5
1.55
1.6
Is there a way to force the trailing 0 to appear?
有没有办法强制尾随0出现?
(I'm using a DevExpress SpinEdit control and trying to set the display and edit format.)
(我正在使用DevExpress SpinEdit控件并尝试设置显示和编辑格式。)
5 个解决方案
#1
yourNumber.ToString("N2");
#2
You can use syntax like this:
你可以使用这样的语法:
String.Format("{0:0.00}", n)
#3
On those rare occasions I need to formatting, I go here:
在极少数情况下,我需要格式化,我去这里:
http://blog.stevex.net/index.php/string-formatting-in-csharp/
#5
spinEdit.Properties.DisplayFormat.FormatType = FormatType.Numeric;
spinEdit.Properties.DisplayFormat.FormatString = "C2";
In the future, though, I would recommended searching Dev Express' knowledge base or emailing support (support@devexpress.com). They'll be able to answer your question in about a day.
但是,在将来,我会建议搜索Dev Express的知识库或通过电子邮件发送支持(support@devexpress.com)。他们将能够在大约一天内回答您的问题。
#1
yourNumber.ToString("N2");
#2
You can use syntax like this:
你可以使用这样的语法:
String.Format("{0:0.00}", n)
#3
On those rare occasions I need to formatting, I go here:
在极少数情况下,我需要格式化,我去这里:
http://blog.stevex.net/index.php/string-formatting-in-csharp/
#4
#5
spinEdit.Properties.DisplayFormat.FormatType = FormatType.Numeric;
spinEdit.Properties.DisplayFormat.FormatString = "C2";
In the future, though, I would recommended searching Dev Express' knowledge base or emailing support (support@devexpress.com). They'll be able to answer your question in about a day.
但是,在将来,我会建议搜索Dev Express的知识库或通过电子邮件发送支持(support@devexpress.com)。他们将能够在大约一天内回答您的问题。