访问propertyinfo中的属性

Ran*_*agg 2 .net c# reflection

我需要通过Tag类在BFrame类中设置Value属性.

我怎么设置Value房产?

澄清:
我不是试图在类中设置Frame属性的值,Tag而是设置Value属性Frame类型的属性BFrame.

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;
}
Run Code Online (Sandbox Code Playgroud)

Hes*_*ehr 6

投返回值GetValueBFrame

var bFrame = (BFrame) frameProperty.GetValue(tag);
bFrame.Value = newValue; 
Run Code Online (Sandbox Code Playgroud)