Why double.TryParse(“0.0000”, out doubleValue) returns false ?

it takes the localization settings at runtime into account… perhaps you are running this on a system where . is not the decimal point but , instead…

In your specific case I assume you want a fixed culture regardless of the system you are running on with . as the decimal point:

double.TryParse("0.0000", NumberStyles.Number, CultureInfo.CreateSpecificCulture ("en-US"), out temp)

OR

double.TryParse("0.0000", NumberStyles.Number,CultureInfo.InvariantCulture, out temp)

Some MSDN reference links:

  • Double.TryParse(String, NumberStyles, IFormatProvider, Double)
  • CultureInfo.CreateSpecificCulture(String)
  • IFormatProvider Interface
  • CultureInfo.InvariantCulture Property

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)