[Solved] Why does double.TryParse(“6E02”, out tempDouble) return true?


By default, double.TryParse uses the following flags from NumberStyles:

  • NumberStyles.AllowThousands
  • NumberStyles.Float, which is an alias for the following combination:
    • NumberStyles.AllowLeadingWhite
    • NumberStyles.AllowTrailingWhite
    • NumberStyles.AllowLeadingSign
    • NumberStyles.AllowDecimalPoint
    • NumberStyles.AllowExponent

You can use the other overload of TryParse to specify only a subset of these to your liking. In particular, you want to remove (at least) the AllowExponent flag.

0

solved Why does double.TryParse(“6E02”, out tempDouble) return true?