MultiCultural OutputFormat

Posted by: michael.mayfield on 6 November 2019, 2:27 am EST

    • Post Options:
    • Link

    Posted 6 November 2019, 2:27 am EST

    We have a multi culture app that needs to use various decimal places for quite a few languages.

    Decimal => 50000.654

    en-US N2 => 50,000.65

    hu-HU N4 => 50 000,6540

    How do you use N3 as an outputformat string?

    OutputFormat = “{0:N2}” for value of 5000.654m has a printed results of {50001:N2}

    // change culture
          CultureInfo hungaryCulture = new CultureInfo("hu-HU");
          hungaryCulture.NumberFormat.NumberNegativePattern = 4;
          Thread.CurrentThread.CurrentCulture = hungaryCulture;
    
    	this.Gross.OutputFormat = "{0:N2}";
    
    

    I also tried to use an outputFormat = “# ##0,00” but it didn’t recognize the format though it did not have any errors.

    Thanks

  • Posted 6 November 2019, 3:45 am EST

    I’ve figured it out.

    Set the OutputFormat to basically the English version, “#,##0.000”, set the textbox Culture and bingo. It returns, 1 234,567, which is correct.

    Close the ticket.

    Thanks

Need extra support?

Upgrade your support plan and get personal unlimited phone support with our customer engagement team

Learn More

Forum Channels