0
我一直在阅读这个的其他例子,我似乎可以通过传递它的名字来赋值我的字段的值。通过传递它的名字来指定一个字段值
private string fieldName; //contains the name of the field I want to edit
void IObserver.Update(object data)
{
FieldInfo field = this.GetType().GetField(fieldName);
if(field != null)
{
field.SetValue(this, data);
}
}
场最终总是空,我无法弄清楚,为什么
请向我们展示这堂课。 – SLaks