0
I have the following doubt, imagine there are two ViewModel
:
public CustoViewModel cvm = new CustoViewModel();
public CustoViewModel custoViewModel= new CustoViewModel();
And that each ViewModel
have your values separated
cvm.cod = 10;
cvm.desc = "Teste";
custoViewModel.cod = 11;
custoViewModel.desc = "Teste";
I’m doing the comparison below and I know it returns me false
if(!cvm.Equals(custoViewModel))
{
//Comentario
}
What I want to know is this: if it’s different, I need to take the field that’s different the way it is:
cvm.cod = custoViewModel.cod;
This in this example becomes easy because I put only two fields, but when there are more fields, then to finish: Is there any way to get the different fields without having to do several if
? (Any way that is different from the one shown below)
if(!cvm.Equals(custoViewModel))
{
if(cvm.cod == custoViewModel.cod)
{
cvm.cod = custoViewModel.cod;
}
if(cvm.desc== custoViewModel.desc)
{
cvm.desc= custoViewModel.desc;
}
}
you do this using Reflection
– Ricardo Pontual
I’ll do a search and see how it works @Ricardopunctual
– Help Me
'Cause you need to do it for a reason?
– novic