I want to display decimal
product price in format 100 грн.
(Ukrainian hryvnia). When I use currency pattern .ToString("c")
I get ₴
sign, I don't want to use it, so I decided to try something like .ToString("#.## грн.")
but the dot isn't displayed. I get грн
output but expect грн.
. How can I accomplish that? I want to use string pattern as the part of the localization so I could use something like .ToString(Settings.CurrencyOutputPattern)
where CurrencyOutputPattern
is "c"
for USD
, "#.## грн."
for UAH
and "#.## руб."
for RUB
You can include a literal .
by enclosing it in single quotes:
.ToString("#.## грн'.'")
you can implement your own extension of String/Decimal to make it to grivan
public string ToGrivna(this decimal ammount)
{
return ammount.ToString("0.##")+" грн."
}
If what you want is to change the currency, then you can clone the CurrentCulture
and modify it.
CultureInfo culture = (CultureInfo)CultureInfo.CurrentCulture.Clone();
culture.NumberFormat.CurrencySymbol = "грн.";
decimal num = 10.24M;
string str = num.ToString("c", culture);
If you want to control where the currency is written (left o right), there are two properties of NumberFormat
: NumberFormatInfo.CurrencyPositivePattern and NumberFormatInfo.CurrencyNegativePattern
For example here in Italy we use € 10.00
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.