烦,因为反射的时候,有那么多属性数据类型不一样的,然后要写好多转换方法?我不想这样做呢,,所以,找啊找,红色标记为
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;
别以为你是男猪脚/女猪脚,其实你是个跑龙套的,只有多点去别人的人生里面跑龙套,你才有机会成为跑龙套王。