2
I’m having trouble making data conversions from a database, for example I perform a query to the bank like this:
carteira ca = bc.carteira.FirstOrDefault(obj => obj.cpf == cepf && obj.codigo == cod);
I receive information of the type ca.valor
, ca.inicio
, ...
I wonder how to convert this value to a type like int, double,...
In order to make the following additions:
int result;
double soma;
int x = ca.valor + result;
double y = ca.inicio + soma;
And so I can use them in a method of my project
chama.meuMetodo(x,y); // x e y seriam int e double
I confess that I forgot how to make this conversion and the your Google is not helping.
You can post to us the Model of the object
carteira
?– Leonel Sanches da Silva
hi I got it. I used the Convert class to do the conversions. for example: int Quant = Convert.Toint32(ca.qtdacao);
– user9090
Is the answer below correct? If so, could you mark it as accepted, for the benefit of the community?
– Leonel Sanches da Silva
@user9090 what is the type of ca.qtdacao?
– Omni
@user9090, the correct thing would be for you to publish your solution as Answer and mark it as correct, if that’s what you used to solve the problem. Check How and why to accept an answer?
– brasofilo