约束属性错误
private int age;//年龄
public int Age
{
get { return age; }
set { if (age>=3&&age <=7) age = value;}
}
{
class Program
{
static void Main(string[] args)
{
Child XioaMing = new Child();
XioaMing.Name = "李晓明";
XioaMing.Sex = "男";
XioaMing.Age = 6;
XioaMing.Height = 125;
Console.WriteLine("我叫"+ XioaMing .Name +",我今年"+ XioaMing.Age +"岁。"+"身高"+XioaMing.Height+"cm.");
XioaMing.PlayBall();
}
}
} 为什么输出年龄为0岁