标签:style blog class code c java
static void Main(string[] args)
{ var retul = GetListData<User>("wang");
} public static List<T> GetListData<T>(string name) where T:class,new()
{
List<string> ls = new List<string>() {"wang","li","zhao" };
PropertyInfo[] pros = typeof(T).GetProperties();
List<T> result = new List<T>();
if(ls.Contains(name))
{
var bb= ls.Where(p=>p =="wang").FirstOrDefault();
T t = new T();
pros[0].SetValue(t,Convert.ChangeType(bb,pros[0].PropertyType),null);
result.Add(t);
}
return result;
}
标签:style blog class code c java
原文地址:http://www.cnblogs.com/Wolfmanlq/p/3733975.html