Hi i want to cast the Parent object to Child object in C#
public class Parent { public string FirstName {get; set;} public string LastName {get; set;
This is what I came up with form my solution.
public static void ShallowConvert(this T parent, U child) { foreach (PropertyInfo property in parent.GetType().GetProperties()) { if (property.CanWrite) { property.SetValue(child, property.GetValue(parent, null), null); } } }