【发布时间】:2011-04-04 04:35:57
【问题描述】:
我使用以下代码:
protected object GetProperty(object target, string fieldName)
{
Type type = target.GetType();
PropertyInfo mi = type.GetProperty(
fieldName, BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.GetProperty);
object obj = mi.GetValue(target, null);
return obj;
}
它适用于 .NET 3.5。但如果我更改为 .NET 4,则 mi 变为 null。为什么?
【问题讨论】:
标签: c# .net .net-3.5 .net-4.0 version-compatibility