Problem with conversion from string to decimal C #

1

Hello, I'm having a problem converting from string to decimal, as the following code demonstrates:

string valor = "0,01";
CultureInfo _provider = new CultureInfo("pt-BR");
decimal valorTratado = Convert.ToDecimal(valor, _provider);

The variable value Treaty should be with a value of 0.01 but it has a value of 1, does anyone know why it happens?

    
asked by anonymous 04.09.2017 / 05:17

1 answer

0

Alexssandro,

Your code should work without problem, I tested it:

This problem can be with the location setting of your computer. Your code is right.

    
06.09.2017 / 21:07