You can use the overload of the Convert.ToDouble
method that receives a IFormatProvider
as a parameter. If Convert.ToDouble
is used without this overload the culture in which the program is running is used. That's why when you convert the value 25.5 it becomes 255 because the "." is a separator of hundreds, not decimal in some cultures (pt-BR being one of these).
Convert.ToDouble(val_serv, System.Globalization.CultureInfo.InvariantCulture)
or
Convert.ToDouble(val_serv, System.Globalization.CultureInfo.GetCultureInfo("pt-BR"));
Convert.ToDouble(val_serv, System.Globalization.CultureInfo.GetCultureInfo("en-US"));
etc ...