public Form1() { InitializeComponent(); First.User user = new First.User() { FirstName = "John", LastName = "Public", UserID = "*****@*****.**" }; Second.User newUser = ConvertUser(user); }
public Second.User ConvertUser(First.User oldUser) { Second.User newUser = new Second.User(); foreach (PropertyInfo prop in oldUser.GetType().GetProperties()) { string propertyName = prop.Name; object propertyValue = prop.GetValue(oldUser); newUser.GetType().GetProperty(propertyName).SetValue(newUser, propertyValue); } return(newUser); }