mardi 8 mai 2018

Access properties inside a propertyinfo

I need to set the Value property inside the BFrame class through the Tag class.

How am I suppose to set the Value property?

class BFrame
{
    string Value{get; set;}
}

class Tag
{
    BFrame Frame{get;}
}

public void func(Tag tag, string newValue)
{
    PropertyInfo frameProperty = tag.GetType().GetProperty("Frame");
    var oldValue = frameProperty.GetValue(tag);
    //frameProperty.SetValue(tag, newValue); //Doesn't work. Throws exception because there is no setter
    //TODO: Set the Value property inside the BFrame class
    //Somethig like this: tag.Frame.Value = newValue;
}





Aucun commentaire:

Enregistrer un commentaire