110,534
社区成员
发帖
与我相关
我的任务
分享
public abstract Parent//父类
{
protected int id = 1;
}
public Child:Parent//子类
{
public Child()
{
this.id = 2
}
}
Parent p = new Child();
MessageBox.Show(p.id.ToString());// 结果2
public abstract Parent//父类
{
protected int id = 1;
}
public Child:Parent//子类
{
}
Parent p = new Child();
p.id = 2;
MessageBox.Show(p.id.ToString());// 结果2