C# 取得对象属性类型
标签:pretty ret obj bsp name 对象 foreach unset 属性
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);
}
}
C# 取得对象属性类型
标签:pretty ret obj bsp name 对象 foreach unset 属性
温馨提示: 本文由杰米博客推荐,转载请保留链接: https://www.jmwww.net/file/14334.html