NumberFormatInfo RRS feed

  • Question

  • User1800958518 posted

    Hi there,

     I'm currently working on an application where the format of the numbers needs to be in the english format (#,##0.00), but currencies needs to be displayed in € .

    Now I can set the Culture in my web.config on en-gb and just put a label behind it with € as the text. (I don't like this).

    So my question is, can I modify the way of displaying the number (or currency) on application level and not formatting each string? I don't want to specify my own custom format in each decimal I create.



    Tuesday, December 19, 2006 9:38 AM


  • User113421904 posted
    The ToString(String) method of int supports output currency format  
    Response.Write(i.ToString("c"));     // The parameter "c" means convert it to currency format
    here is the example:
          int i = 100;
          // Sets the CurrentCulture to French in France.
          Thread.CurrentThread.CurrentCulture = new CultureInfo("fr-FR");
          // Sets the CurrentCulture to French in France, using the
          // CultureInfo constructor that takes a useUserOverride parameter.
          // Sets the useUserOverride value to false. 
          Thread.CurrentThread.CurrentCulture = new CultureInfo("fr-FR", 
          // Displays i formatted as default currency for the CurrentCulture.
          // On a version of Windows prior to Windows XP, this will override an
          // incorrect default setting of "F" and display the euro symbol (€).
    And output:
    100,00 F
    100,00 €
    Please check the example of this link for more information:
    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Wednesday, January 17, 2007 1:58 AM