mardi 6 novembre 2018

Set and get value of the Nested Class by string without class name

I am trying to set and get value to a Nested Property of Class dynamically using reflection. Could anyone help me to do this? I have the next class

    public class Coil
{
    public string StickNo { get; set; }
}

public class CoilFailStation1Parameters : Coil
{
    public Station_101 Station_101 { get; set; }
    public Station_102 Station_102 { get; set; }
}

public class Station_101
{
    public string cam_term_1_val { get; set; }
    public string cam_term_2_val { get; set; }
}
public class Station_102
{
    public string cam_term_3_val { get; set; }
    public string cam_term_4_val { get; set; }
}

I would like to set and get the value like this or something simiar:

coildata["cam_term_1_val"] = "value"; //or
coildata.SetPropValue("cam_term_1_val", "value");





Aucun commentaire:

Enregistrer un commentaire