Mapper

public static void Mapper<T>(T tSource, T tDestination) where T : class
    {
        //获得所有property的信息
        PropertyInfo[] properties = tSource.GetType().GetProperties();
        foreach (PropertyInfo p in properties)
        {
            p.SetValue(tDestination, p.GetValue(tSource, null), null);//设置tDestination的属性值              
        }
    }

 

posted @ 2023-12-14 10:27  极客船长  阅读(12)  评论(0编辑  收藏  举报