使用反射我需要检索a的属性值 Nullable Type of DateTime
我怎样才能做到这一点?
当我尝试propertyInfo.GetValue(object, null)它不起作用.
谢谢
我的代码:
var propertyInfos = myClass.GetType().GetProperties();
foreach (PropertyInfo propertyInfo in propertyInfos)
{
object propertyValue= propertyInfo.GetValue(myClass, null);
}
Run Code Online (Sandbox Code Playgroud)
propertyValue结果对于可空类型始终为null