Home Current culture - display euro symbol (€) instead of EUR string
Reply: 1

Current culture - display euro symbol (€) instead of EUR string

UrAn Published in 2017-09-11 12:20:04Z

With current culture set to "sk-SK" (Slovakia with currency - euro) I want to show euro symbol (€) instead of "EUR" string when displaying price as currency in Razor with Price.ToString("c").

When I change current culture to, for example German ("de-DE"), the euro symbol (€) is displayed.

I would like to show euro symbol when displaying price with Slovak culture as well (not "EUR" string).

I think this is OS dependent (our OS is Windows Server 2012) but changing default currency suggested by this article: https://www.howtogeek.com/240216/how-to-change-windows-default-currency-from-dollars-to-euros/ (in our case from EUR to €) doesn't change the way currency symbol is displayed. How can I display the currency as € instead of EUR?

waka Reply to 2017-09-11 13:30:04Z
CultureInfo ci = new CultureInfo("sk-SK");
ci.NumberFormat.CurrencySymbol = "€";
CultureInfo.DefaultThreadCurrentCulture = ci;
double Price = 10.0;

This produces the output

10,00 €

Another possibility is to pass the culture info as IFormatProvider in ToString():

You need to login account before you can post.

About| Privacy statement| Terms of Service| Advertising| Contact us| Help| Sitemap|
Processed in 0.525597 second(s) , Gzip On .

© 2016 Powered by cudou.com design MATCHINFO