Search code examples
c#visual-studiocurrency

Visual studio 2015 - How to change default currency?


So, I'm working on a simple program to display a quantity as currency, but it is displayed as euros, I would like it to be displayed as dollars.

I have read that it may be because of the region or something related, but I´m in Mexico, I don´t know why it would be displayed as euros if what I read is true.

How can I solve this? Thanks!


Solution

  • You need to change the CultureInfo that your app is running under.

    You can change the current thread, based on a language-culture combination. Just do the following:

    System.Threading.Thread.CurrentThread.CurrentUICulture = new CultureInfo("en-US");
    

    If you're looking for more granular control, you can create a CultureInfo and specify when formatting strings.

    CultureInfo currentCulture = CultureInfo.GetCultureInfo("en-US"); 
    var formattedVal = string.Format(currentCulture , "{0:C}", 12500.55);