Yoavo wrote:
Hi,
I want to convert a string to double. I use the function:
"System.Convert.ToDouble".
The problem is that if the string contains the character "." the program
aborts.
What might be the problem ?
Yoav.
The ToDouble method is using a NumberFormat object that specifies
different characters for decimal separator and thousands separator than
what you have in the string.
The method uses the NumberFormat of the CultureInfo.CurrentCulture object.
You can use the Double.Parse method instead, so that you can specify the
FormatInfo or CultureInfo object directly. For a string that uses a
period as decimal separator, you can use the InvariantCulture object:
string s = "2.1415926536";
double d = double.Parse(s, CultureInfo.InvariantCulture);
--
Göran Andersson
_____
http://www.guffa.com