[英]How to display dot using Custom Numeric Format Strings in C#
我想以100 грн.
格式显示decimal
产品价格100 грн.
(乌克兰格里夫纳汇率)。 当我使用货币模式.ToString("c")
我得到了₴
符号,我不想使用它,因此我决定尝试使用诸如.ToString("#.## грн.")
但点号不是' t显示。 我得到грн
输出,但期望грн.
。 我该怎么做? 我想使用字符串模式作为本地化的一部分,所以我可以使用.ToString(Settings.CurrencyOutputPattern)
类的东西,其中CurrencyOutputPattern
对于USD
是"c"
,是"#.## грн."
UAH
和"#.## руб."
为RUB
您可以包括文字.
通过将其用单引号引起来:
.ToString("#.## грн'.'")
您可以实现自己的String / Decimal扩展名使其成为grivan
public string ToGrivna(this decimal ammount)
{
return ammount.ToString("0.##")+" грн."
}
如果要更改货币,则可以克隆CurrentCulture
并进行修改。
CultureInfo culture = (CultureInfo)CultureInfo.CurrentCulture.Clone();
culture.NumberFormat.CurrencySymbol = "грн.";
decimal num = 10.24M;
string str = num.ToString("c", culture);
如果要控制货币的书写位置(从左到右),则NumberFormat
有两个属性: NumberFormatInfo.CurrencyPositivePattern和NumberFormatInfo.CurrencyNegativePattern
例如,在意大利,我们使用€10.00
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.