this关键字

this关键字

1)代表当前类的对象

2)在类当中显示的调用本类的构造函数  : this

//类里面可以写 字段、属性、方法、构造函数
        public Student(string name, int age, char gender, int chinese, int math, int english)//创建对象的时候会执行构造函数
        {
            this.Name = name;
            this.Age = age;
            this.Gender = gender;
            this.Chinese = chinese;
            this.Math = math;
            this.English = english;
        }
        public Student(string name, int chinese, int math,int english):this(name,0,'a',chinese,math,english)//构造函数可以进行重载
        {
            //this.Enlish = english;
            //this.Math = math;
            //this.Chinese = chinese;            
        }

 

posted @ 2021-06-15 19:27  静态类  阅读(43)  评论(0编辑  收藏  举报