gbr
July 15th, 2005, 05:31 AM
Hi,
as I found out C# does conversion of float strings in different ways on different OS (e.g. english WindowsXP and german WindowsXP).
For example if I execute:
string st = "100.00";
float fl = (float)System.Convert.ToDouble(st);
MessageBox.Show( st + "-->" + fl.ToString() );
st = "37,00";
fl = (float)System.Convert.ToDouble(st);
MessageBox.Show( st + "-->" + fl.ToString() );
I get "10000" and "37" for the converted floats on the german OS. However if I execute the same stripped of code on an english Windows it converts to "100" and "3700".
I can imagine what went wrong, but I don't know how to fix that issue. The question is: how to tell the application what to use as a float separator no matter what kind of language is used, because one can assume that internally all float strings are handled in "12.345" format.
Thanks in advance,
gbr
as I found out C# does conversion of float strings in different ways on different OS (e.g. english WindowsXP and german WindowsXP).
For example if I execute:
string st = "100.00";
float fl = (float)System.Convert.ToDouble(st);
MessageBox.Show( st + "-->" + fl.ToString() );
st = "37,00";
fl = (float)System.Convert.ToDouble(st);
MessageBox.Show( st + "-->" + fl.ToString() );
I get "10000" and "37" for the converted floats on the german OS. However if I execute the same stripped of code on an english Windows it converts to "100" and "3700".
I can imagine what went wrong, but I don't know how to fix that issue. The question is: how to tell the application what to use as a float separator no matter what kind of language is used, because one can assume that internally all float strings are handled in "12.345" format.
Thanks in advance,
gbr