C# 取得对象属性类型
1、对象 Object obj
;
2、对象属性
Type postType = obj.GetType();
PropertyInfo[] postTypeInfos = postType.GetProperties();
3、对象属性类型
foreach (PropertyInfo p in postTypeInfos)
{
if (p.PropertyType.FullName == typeof(DateTime).FullName)
{
Object pValue = p.GetValue(obj, null);
}
else if (p.PropertyType.FullName == typeof(Int32).FullName)
{
Object pValue = p.GetValue(obj, null);
}
else if (p.PropertyType.FullName == typeof(Boolean).FullName)
{
Object pValue = p.GetValue(obj, null);
}
else if (p.PropertyType.FullName == typeof(String).FullName)
{
Object pValue = p.GetValue(obj, null);
}
else if (p.PropertyType.FullName == typeof(List<Address>).FullName)
{
List<Address> list = (List<Address>)p.GetValue(obj, null);
}
}
"唯有高屋建瓴,方可水到渠成"