分析如下C#代码,根据类的继承关系,运行后的输出结果是( )。 (选择一项)
public class Person{
private int age=10;
public int Age {
get{return age;}
set{
age = value;
Console.Write("请勿入内!");
}
}
}
public class People:Person{
public People(){
if (this.Age >=18)
Console.Write("成年人!");
else
Console.Write("非成年人!");
}
}
public class Test{
static void Main(){
People Shang=new People();
Shang.Age =50;
Console.ReadLine ();
}
}
a) 请勿入内!
b) 非成年人! 请勿入内!
c) 请勿入内!成年人!
d) 成年人! 请勿入内!
回复 net960725606: 咳咳..我已经说了答案是B了 ....回答问题时要带解释