mardi 28 février 2017

call properties through a string object with c # - Xamarin forms

I have an object of 500 properties, my need is to call the object dynamically using string. How can I do using c #?

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; }

}

my goal would be to call

var x = MyObjects.Equals ( "RGP_IDREG_1");

it's possible ? Reflection?





Aucun commentaire:

Enregistrer un commentaire