Convert string to double by specifying decimal separator

2

Please collaborate with the following, I want to convert a string to double but specifying the decimal separator, example

String a = "123,45";
String b = "987.65";
//Requiero uno conversión especificando el separador, no se algo como lo siguiente
double ad = Double.Parse(a,",");
double bd = Double.Parse(b,".");

Preferably be on vb.net

Greetings.

    
asked by RSillerico 08.06.2016 в 22:44
source

1 answer

1

I found the answer in this link:

link

As you can see it is defined:

NumberFormatInfo provider = new NumberFormatInfo();
provider.NumberDecimalSeparator = ",";

and the conversion is done with:

string value = "123,23";
Double k = Convert.ToDouble(value, provider));

Where value is the string you want to convert.

Greetings

    
answered by 08.06.2016 в 23:34