【发布时间】:2010-03-03 11:52:36
【问题描述】:
我正在通过以下代码检索 IEnumerable 属性列表:
BindingFlags bindingFlag = BindingFlags.Instance | BindingFlags.Public;
var dataProperties = typeof(myParentObject).GetProperties(bindingFlag);
然后我遍历列表并检索每个属性的值。
我遇到了两种不同的方法来做到这一点,只是想知道它们之间有什么区别:
1)
object propertyValue = property.GetGetMethod().Invoke(myObject, null);
2)
object propertValue = property.GetValue(myObject, null)
【问题讨论】:
标签: reflection c#-2.0