p p1 = new p();
p1.ID = 12;
p1.Name = "wo shi p";
s s1 = new s();
s1.BaseModel = p1;
s1.Age = 15;
public class p
{
private int id;
public int ID
{
get { return id; }
set { id = value; }
}
private string name;
public string Name
{
get { return name; }
set { name = value; }
}
}
public class s : p
{
public p BaseModel
{
get { return (p)this;}
set
{
PropertyInfo[] propertys =value.GetType().GetProperties();
for (int i = 0; i < propertys.Length; i++)
{
this.GetType().GetProperty(propertys[i].Name).SetValue(this,propertys[i].GetValue(value, null),null);
}
}
}
private int age;
public int Age
{
get { return age; }
set { age = value; }
}
}