题目:
1.设计一个表示学生的类Student。学生类创建好之后,可以创建学生对象。然后调用speak()方法输出学生信息姓名name,性别sex,年龄age等。
2.使用属性,防止外界对类中的成员变量随意访问。
3.为Student编写两个以上的构造方法,其中一个无参数,测试这些构造方法。
4.为Student类编写析构方法
情况一:
自己琢磨的
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace 学生
{
class Program
{
static void Main(string[] args)
{
Student.speak();
GC.Collect();//回收垃圾
Console.ReadLine();
}
}
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace 学生
{
class Student
{
string name;
public string Name//都得是public???不是不让外来访问嘛
{
get {
return name; }
set {
name = value; }
}
string sex