日期:2014-05-17 浏览次数:20418 次
public static T CopyToT<S>(S source) where S:new()
{
T result = new T();
Type type = typeof(T);
PropertyInfo[] properties = type.GetProperties();
PropertyInfo[] sProperties = typeof(S).GetProperties();
foreach (var item in properties)
{
try
{
//if source has this Property
bool flag = false;
foreach (var q in sProperties)
{
if (q.ToString() == item.ToString())
{
flag = true;
}
}
if (flag)
{