jeudi 5 janvier 2017

Reflection C# to idenfify and sum

I'm trying to identify a property through reflection in c# then sum this value, but I think I'm using this in incorrect form. Anyone can help me?

code:

var salarioTotal = 0.0;
foreach (var item in T.GetType().GetProperties())
{                     
  if (item.Name.ToString() == "Salario")
    salarioTotal += (Double)item.GetValue(T, null);

  String campo = (Convert.ToString(salarioTotal));

  item.SetValue(T, campo);
}
return T;





Aucun commentaire:

Enregistrer un commentaire