111,023
社区成员
发帖
与我相关
我的任务
分享
public class UserCopy
{
public class LoginEntity
{
public string UserName { get; set; }
public string UserPwd { get; set; }
public DateTime ActiveTime { get; set; }
}
public class UserEntity : LoginEntity
{
public string UserID { get; set; }
public Int16 UserSex { get; set; }
public Int32 UserAge { get; set; }
}
protected void UserCopy()
{
List<UserEntity> ueList = new List<UserEntity>() {
new UserEntity(){
UserID="U1",
UserName="U1",
UserPwd="U1PWD",
ActiveTime=DateTime.Now
},
new UserEntity(){
UserID="U2",
UserName="U2",
UserPwd="U2PWD",
ActiveTime=DateTime.Now},
new UserEntity(){
UserID="U2",
UserName="U2",
UserPwd="U2PWD",
ActiveTime=DateTime.Now}
};
List<LoginEntity> leList = new List<LoginEntity>();
//方法一:遍历
ueList.ForEach(ue => leList.Add(new LoginEntity()
{
UserName = ue.UserName,
UserPwd = ue.UserPwd,
ActiveTime = ue.ActiveTime
}));
}
}