Home > database >  C# Wrong Decimal Parse/Conversion
C# Wrong Decimal Parse/Conversion

Time:12-19

Im trying to parse or convert the string "3045.00" (three thousand forty-five) but it always returns 304500.0 (three hundred four thousand five hundred).

The ways that i tried to:

Convert.ToDecimal("3045.00")

Decimal.Parse("3045.00")

Someone could help me? Thanks.

CodePudding user response:

Providing the InvariantCulture causes parsing to use the . character as the thousands separator (instead of the decimal separator)

Console.WriteLine(decimal.Parse("3045.00", CultureInfo.InvariantCulture)); //"3045.00"
  • Related