Merge the state of two objects in C# using reflection
if (fromObject == null || toObject == null) { return; } PropertyInfo[] properties = typeof(T).GetProperties(); object value = null; for (int i = 0; i < properties.Length; i++) { if (!properties[i].CanWrite) { continue; } value = null; IList list = properties[i].GetValue(fromObject, null) as IList; if (list != null) { //Is a list. value = ...