Ben Junior
Ben Junior

Reputation: 2589

How to keep only one standard currency symbol ($) when changing cultures?

How can I make the web app only to display currency in dollars, regardless of the language/country selected ?

SetCulture(string culture)
   {
     CultureInfo.DefaultThreadCurrentCulture = new CultureInfo(culture);
     CultureInfo.DefaultThreadCurrentUICulture = new CultureInfo(culture);
   }  


Text = String.Format("{0:C}", item.TotCostDay);

Upvotes: 0

Views: 84

Answers (1)

Dmitrii Bychenko
Dmitrii Bychenko

Reputation: 186668

You can try creating a Clone of current culture with NumberFormat.Currency... modified:

CultureInfo culture = CultureInfo.CurrentCulture.Clone() as CultureInfo;

CultureInfo usCulture = CultureInfo.GetCultureInfo("en-US");

// Dollar symbol - $
culture.NumberFormat.CurrencySymbol = usCulture.NumberFormat.CurrencySymbol;

// And (may be) some US currency patterns
culture.NumberFormat.CurrencyDecimalDigits = usCulture.NumberFormat.CurrencyDecimalDigits;
culture.NumberFormat.CurrencyPositivePattern = usCulture.NumberFormat.CurrencyPositivePattern;
culture.NumberFormat.CurrencyNegativePattern = usCulture.NumberFormat.CurrencyNegativePattern;

CultureInfo.CurrentCulture = culture;

Upvotes: 1

Related Questions