locked
Problem in decimal values calculation if we change the language RRS feed

  • Question

  • User-1998050186 posted

    If i want to calculate decimal values.Currently I have choosed current culute as US.and my calculation is perfect.If I changed  the current UICulture of the application as Spanish.Then application show exception in decimal values


    Saturday, December 19, 2009 7:52 AM

Answers

  • User187056398 posted

    Are you parsing input numbers?  Some cultures reverse the dot and comma characters:

             Decimal Temp1 = Decimal.Parse("123,456.78", CultureInfo.CurrentCulture.NumberFormat);
    
             Decimal Temp2 = Decimal.Parse("123.456,78", CultureInfo.GetCultureInfo("es-ES").NumberFormat);
    


     

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Saturday, December 19, 2009 11:01 AM

All replies

  • User187056398 posted

    Are you parsing input numbers?  Some cultures reverse the dot and comma characters:

             Decimal Temp1 = Decimal.Parse("123,456.78", CultureInfo.CurrentCulture.NumberFormat);
    
             Decimal Temp2 = Decimal.Parse("123.456,78", CultureInfo.GetCultureInfo("es-ES").NumberFormat);
    


     

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Saturday, December 19, 2009 11:01 AM
  • User-1998050186 posted

    I have applied your code but exception still there

    Sunday, January 10, 2010 3:27 AM
  • User187056398 posted

    If you have code that is causing an exception and need help, you'll have better luck if you post the code and exception.

    Sunday, January 10, 2010 8:33 AM