Issue with decimals

I found an issue in decimals when I try to parse a string data to double. For example:

I introduce 2.5 from smartphone and when I apply the parse to double from code of Xamarin, it takes the value like an integer and that affects my calculations.


  • DaveHuntDaveHunt USMember ✭✭✭✭✭

    The culture info for your environment probably specifies a ',' as the decimal separator and a '.' as the thousands separator. You need to use invariant culture when converting strings with '.' for decimals:

    double.Parse("2.5", CultureInfo.InvariantCulture)

    should solve your problem.

  • MaxNunezMaxNunez CRMember ✭✭

    Thanks @DaveHunt I will try with that.

  • MaxNunezMaxNunez CRMember ✭✭

    It was very useful your recommendation thanks for your help

  • DaveHuntDaveHunt USMember ✭✭✭✭✭

    You're very welcome!

Sign In or Register to comment.