zoukankan      html  css  js  c++  java
  • c#中new hisase关键字


    9.new关键字的作用
    person zsPerson = new person();

    1)在内存中开辟一块空间
    2)在开辟的空间中创建对象
    3)调用对象的构造函数进行初始化对象。

    :base()关键字是在父类中申明了有参数构造函数,创建子类对象时,不能调用父类中默认无参构造函数,故需要在子类构造函数中使用:base()显示调用父类中的有参构造函数,进行初始化。

    10.this关键字
    作用:
    1)代表当前对象
    2)在同一个类中显示的调用构造函数 :this()
    主要是作用与同一个类中,一个构造函数显示调用另一个构造函数。
     public Student(string name, char gender, int age, int chinese, int match, int english)
            {
                Name = name;
                Gender = gender;
                Age = age;
                Chinese = chinese;
                Match = match;
                English = english;
            }
            //在下面这个构造函数中调用上面这个构造函数实现对象实例化public Student(string name , int chinese ,int match , int english):this(name ,'女' ,12 ,chinese ,match ,english)
            {     
            }

  • 相关阅读:
    javaScript对象
    javaScript基础
    使用javaScript和JQuery制作经典面试题:光棒效果
    Animate自定义动画
    使用jQuery快速高效制作网页交互特效
    jQuery中绑定事件bind() on() live() one()的异同
    小笔记1(Get请求)

    this关键字
    Eclipse断点调试(下)
  • 原文地址:https://www.cnblogs.com/jefy/p/9207565.html
Copyright © 2011-2022 走看看