Yes, you can do this via reflection.
Read the properties of both the instances and assign them with the help of reflection.
Here's some code..
public static void AssignSourceToDestination(Object source, ref Object destination)
{
IList<PropertyInfo> sourceProps = source.GetProperties();
IList<PropertyInfo> destProps = destination.GetProperties();
foreach (PropertyInfo property in destProps)
{
if (property.CanWrite)
{
PropertyInfo sourceProp = sourceProps.Where(p => p.Name.Equals(property.Name) &&
p.PropertyType.Equals(property.PropertyType) && p.CanRead).First();
if (null != sourceProp)
property.SetValue(destination, sourceProp.GetValue(source, null), null);
}
}
}
public static IList<PropertyInfo> GetProperties(this Object me)
{
return me.GetType().GetProperties(BindingFlags.Public | BindingFlags.Instance).ToList();
}