标签:
public object SetDefault(object obj)
{
PropertyInfo[] fields = obj.GetType().GetProperties();
foreach (PropertyInfo v in fields)
{
if(v.PropertyType==typeof(String)&&v.GetValue(obj)==null)
{
v.SetValue(obj, "");
}
else if(v.PropertyType == typeof(DateTime) && (DateTime)v.GetValue(obj)==DateTime.MinValue)
{
v.SetValue(obj, DateTime.Now);
}
}
return obj;
}
标签:
原文地址:http://www.cnblogs.com/moye8187/p/5824239.html