标签:style color io ar for sp 数据 on cti
烦,因为反射的时候,有那么多属性数据类型不一样的,然后要写好多转换方法?我不想这样做呢,,所以,找啊找,红色标记为
Type _type = typeof(T);
System.Reflection.PropertyInfo[] info = _type.GetProperties();
T t = (T)_type.Assembly.CreateInstance(_type.FullName);
foreach (var temp in info)
{
TextName tn = listTextName.Where(p => p.FieldName == temp.Name).FirstOrDefault();
if (tn == null) continue;
var tempValue = tn.TextValue;
temp.SetValue(t, Convert.ChangeType(tn.TextValue, temp.PropertyType), null);
}
return t;
标签:style color io ar for sp 数据 on cti
原文地址:http://www.cnblogs.com/Limit-v/p/4046397.html