1、定义一个学生类Student
【问题描述】
定义一个学生类Student,该类具有学生姓名、年龄、身高、年级等成员,其中姓名为公有,其他成员为私有,并完成该类构造函数和析构函数的创建。
【参考代码】
class Student{public string name;private int age;private int height;private string grade;public Student(){this.name = "zhangsan";this.age = 18;this.height = 180;this.grade = "信管121";}public Student(string na, int a, int h, string g){this.grade = g;this.name = na;this.height = h;this.age = a;}public static void Main(){Student stu1 = new Student();Console.WriteLine("学生姓名:{0}\n学生年龄:{1}\n学生身高:{2}\n学生班级{3}\n",stu1.name, stu1.age, stu1.height, stu1.grade);Student stu2 = new Student("lisi", 20, 175,"信息121");Console.WriteLine("学生姓名:{0}\n学生年龄:{1}\n学生身高:{2}\n学生班级{3}\n", stu2.name, stu2.age, stu2.height, stu2.grade);Console.ReadLine();}
}