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)