如何插入千位分隔符(逗号)与转换为双精度 [英] How to insert a thousand separator (comma) with convert to double
问题描述
我正在尝试格式化文本框的内容:
I am trying to format the contents of a text box:
this.lblSearchResults1.Text =
Convert.ToDouble(lblSearchResults1.Text).ToString();
如何对此进行修改,以使文本包含逗号/千位分隔符?
How do I amend this so that I the text includes comma/thousand separators?
即1000,而不是1000.
i.e. 1,000 instead of 1000.
推荐答案
对于完整的自定义控件,请使用... .ToString("#,##0.00")
或其变体. .
和,
将替换为与文化相关的符号.在欧洲大部分地区,您将获得1.234,56.
另一个有用的图片是0.0#
.
For complete custom control, use ... .ToString("#,##0.00")
or variations thereof. The .
and ,
will be replaced by culture dependent symbols. In most of europe you'd get 1.234,56.
Another useful picture is 0.0#
.
要根据用户(或所选)区域性使用模式,请使用,如.ToString("N")
或"... {0:N}"
所示.
To use a pattern depending on the users (or on a selected) culture, use The Numeric ("N") Format Specifier, as in .ToString("N")
or "... {0:N}"
.
这篇关于如何插入千位分隔符(逗号)与转换为双精度的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!