decimal field by taking the comma c #

0

Good afternoon,

I made an assignment as follows:

dadosRedistribuicao.QUANTIDADE = (Decimal.Parse(txtDisponivel.Text) * Decimal.Parse(percentual)) + Decimal.Parse(distribuicao);

dataRedistribution.QUANTITY is of the decimal type, so I'm converting what comes from the text field. The percentage variable and distribution comes from a grid and goes like this:

string distribuicao = gvMaterial.Rows[i].Cells[2].Text;
string percentual = gvMaterial.Rows[i].Cells[3].Text;

The value of the txtAvailable is 113, the value of the percentage is 0.77 and the value of the distribution is 1. the result was to be 88.01, but it is coming 8702, can someone tell me what?

Thank you in advance.

    
asked by anonymous 28.03.2018 / 19:30

1 answer

0

This Calculation:

    string distribuicao = "1";
    string percentual = "0,77";
    string disponivel = "113";

    decimal quantidade = decimal.Parse(disponivel) * decimal.Parse(percentual) + decimal.Parse(distribuicao);

Results: 8702

DotNetFiddle

The correct one, would be this:

    string distribuicao = "1";
    string percentual = "0.77";
    string disponivel = "113";

    decimal quantidade = decimal.Parse(disponivel) * decimal.Parse(percentual) + decimal.Parse(distribuicao);

Result: 88.01

DotNetFiddle

  

The only difference is the percentage separator.

    
28.03.2018 / 19:49