/// <summary> /// TIntoTOut /// </summary> /// <typeparam name="TIn"></typeparam> public static TOut ClassToClass<TIn,TOut>(TIn tIn) { TOut tOut = Activator.CreateInstance<TOut>(); var tInType = tIn.GetType(); foreach (var itemOut in tOut.GetType().GetProperties()) { var itemIn = tInType.GetProperty(itemOut.Name); if (itemIn != null) { itemOut.SetValue(tOut, itemIn.GetValue(tIn)); } } return tOut; }
标签:克隆,itemIn,var,tIn,tOut,泛型,net,itemOut From: https://www.cnblogs.com/Cabbager/p/18143107