0

I'm trying to convert a string value to Double but I sill get error saying that the format is incorrect.

My Strings are represented like this : 7.346000E-001, 7.3460000E+000

Is there another way to convert them or I need to truncate the string into two parts and do the calculation by myself to get the real value ?

Wassim AZIRAR
  • 10,823
  • 38
  • 121
  • 174

2 Answers2

2

Try CultureInfo.InvariantCulture with double.parse

System.Threading.Thread.CurrentThread.CurrentCulture = new CultureInfo("fr-FR"); // just to simulate french culture
double d = double.Parse("7.3460000E-001",CultureInfo.InvariantCulture);
Console.Write(d);
Habib
  • 219,104
  • 29
  • 407
  • 436
1

French culture (I assumed it from your profile) uses comma instead of the dot as the decimal separator.

Solution described here: C# float.tryparse for French Culture

Community
  • 1
  • 1
Artem Koshelev
  • 10,548
  • 4
  • 36
  • 68