Try the following by adding into your Class2: This would set your class1(SynMed) properties from class2 properties:
public void SynMedFill(ref synMed _synMed)
{
Type ReflectionDataObject = this.GetType();
object classDataObject = this;
Type ReflectionObject = _synMed.GetType();
if (ReflectionObject != null)
{
foreach (PropertyInfo propertyInfo in ReflectionObject.GetProperties())
{
string pName = propertyInfo.Name;
var pinfo = ReflectionDataObject.GetProperty(pName);
if (pinfo != null)
{
var valueVar = ReflectionDataObject.GetProperty(pName).GetValue(classDataObject, null);
try
{
ReflectionObject.GetProperty(pName).SetValue(_synMed, Convert.ToString(valueVar), null);
}
catch (Exception e)
{
}
}
}
}
}
Sample use:
synMed syn = new synMed();
test2 t = new test2();
t.FirstName = "Help";
t.LastName = "IdontKnow";
t.SynMedFill(ref syn);