6
I need to convert a String value (returned by the database) to Double but when I do, it simply modifies the value. Example: the database returns 22.5, when I convert to Double at 225.0.
String val_serv = consultaserv[2].ToString();
Double buffer = Convert.ToDouble(val_serv);
totalserv = buffer + totalserv;
Could you explain that? Why the original
Convert.ToDouble
is wrong? So we can all understand the problem. = D– Miguel Angelo
Not that I’m wrong, but that this
Convert.ToDouble()
does not take into account that thestring
has a format to be read. In the case ofParse
, use theInvariantCulture
, which forces the method to convert thestring
for the most widely used format worldwide.– Leonel Sanches da Silva