. NET Learning notes----2015-07-16 (C # Basics review 02)

Source: Internet
Author: User

Review of inheritance

Effectively solve code redundancy, achieve polymorphism: Increase code scalability, ease of maintenance

1, single-sex

2, Transmission of

The subclass does not inherit the constructor of the parent class, but instead calls the parent class's parameterless constructor by default

    classProgram {Static voidMain (string[] args) {        }    }     Public classPerson {//Public Person ()//{ }         PublicPerson (stringNameintAgeChargender) { }         Public stringName {Get;Set; }  Public intAge {Get;Set; }  Public CharGender {Get;Set; }  Public voidChlss () {}} Public classStudent:person {//call the constructor of the parent class in the subclass, using the keyword base         PublicStudent (stringNameintAgeCharGenderintID):Base(name, age, gender) { This. ID =ID; }        //Automatic Properties         Public intID {Get;Set; }  Public voidChlss () {}} Public classTeacher:person { PublicTeacher (stringNameintAgeCharGenderDoublesalary):Base(name, age, gender) { This. Salary =salary; }         Public DoubleSalary {Get;Set; }  Public voidChlss () {}}

. NET Learning Note----2015-07-16 (C # Foundation Review)

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.