在线请教高人……
如下代码中是一个Person的父类 的代码
![](https://images.cnblogs.com/OutliningIndicators/ContractedBlock.gif)
1 #region Person类
2 public class Person
3 {
4 private string name;
5 private uint age;
6 Student student = new Student("aaaaaaaaaa",444);
7 public Person(string name, uint age)
8 {
9 this.name = name;
10 this.age = age;
11 Console.WriteLine("父类调用构造函数");
12 }
13 public string Name
14 {
15 get { return name; }
16 set { name = value; }
17 }
18 public uint Age
19 {
20 get { return age; }
21 set { age = value; }
22 }
23 }
24 #endregion
2 public class Person
3 {
4 private string name;
5 private uint age;
6 Student student = new Student("aaaaaaaaaa",444);
7 public Person(string name, uint age)
8 {
9 this.name = name;
10 this.age = age;
11 Console.WriteLine("父类调用构造函数");
12 }
13 public string Name
14 {
15 get { return name; }
16 set { name = value; }
17 }
18 public uint Age
19 {
20 get { return age; }
21 set { age = value; }
22 }
23 }
24 #endregion
如下是一个Student继承Person类的代码
![](https://images.cnblogs.com/OutliningIndicators/ContractedBlock.gif)
1 #region Student继承Person类
2 public class Student : Person
3 {
4 private string sex;
5 public string Sex
6 {
7 get { return sex; }
8 set { sex = value; }
9 }
10 public Student(string bb,uint aa):base ("f",5)
11 {
12 base.Name = bb;
13 Console.WriteLine ("子类调用构造函数{0}",base.Name = bb);
14 }
15 }
16 #endregion
2 public class Student : Person
3 {
4 private string sex;
5 public string Sex
6 {
7 get { return sex; }
8 set { sex = value; }
9 }
10 public Student(string bb,uint aa):base ("f",5)
11 {
12 base.Name = bb;
13 Console.WriteLine ("子类调用构造函数{0}",base.Name = bb);
14 }
15 }
16 #endregion
下面是我在Main函数里进行的调用,如下
1 static void Main(string[] args)
2 {
3 Student stu = new Student("aa", 3);
4 Console.Read();
5
6 }
2 {
3 Student stu = new Student("aa", 3);
4 Console.Read();
5
6 }
以上代码存在一个问题,搞不懂为什么会出现这种问题,请教高人………… 在线等……