Search code examples
c#globalization

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);

Solution

  • 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;