I have an object 500 parameters, and I can not change it, because it is a shared project. My goal is to get the property value with the reflection, but I can not do it.
here is my code that:
public class MyObjects
{
public int RGP_Id { get; set; }
public DateTime RGP_DateTime { get; set; }
public int RGP_MCC_Numero_Serie_MS { get; set; }
public int RGP_IDREG_1 { get; set; }
public int RGP_IDREG_2 { get; set; }
public int RGP_IDREG_3 { get; set; }
public int RGP_IDREG_4 { get; set; }
public int RGP_IDREG_5 { get; set; }
public int RGP_IDREG_6 { get; set; }
public int RGP_IDREG_7 { get; set; }
public int RGP_IDREG_8 { get; set; }
public int RGP_IDREG_9 { get; set; }
public int RGP_IDREG_10 { get; set; }
.......
public int RGP_IDREG_500 { get; set; }
}
...
var profile = MyObjects;
var idProperty = GetProperty(profile.GetType().GetTypeInfo(), "RGP_IDREG_10");
...
idProperty contains the object, and up there I did.
Now, how can I do to recover the value using idProperty? basically I would get:
var x = MyObjects.idProperty;
solutions ?
Aucun commentaire:
Enregistrer un commentaire