1,代表当前类的实例化对象
2,能显示的调用当前类的构造方法
public class Student{
public string name;
public int age;
public string gender;
public Student(string name,int age,string gender)
{
this.name=name;
this.age=age;
this.gender=gender;
}
//先是调用构造方法
public Student(string name,string gender):this(name,0,gender)//0为年龄的默认值
{
//其他操作
}
}
注意:
this和base均为类的预定义对象,其属于类的对象,不属于类,静态方法和静态变量属于类,所以在静态方法中不能使用this和base