Interface, the conversion relationship between parent and child classes.

Source: Internet
Author: User

Interface iperson:

Using system; <br/> namespace objectstruct <br/>{< br/> interface iperson <br/>{< br/> int age {Get; set ;} <br/> string name {Get; Set ;}< br/> string sex {Get; Set ;}< br/>}< br/>}

Base Class baseclass:

Using system; <br/> using system. collections. generic; <br/> using system. LINQ; <br/> using system. text; <br/> namespace objectstruct <br/>{< br/> class baseclass: objectstruct. iperson <br/>{< br/> Public baseclass () <br/>{</P> <p >}< br/> Public baseclass (string name, string sex, int age) <br/>{< br/> This. name = Name; <br/> This. sex = sex; <br/> This. age = age; <br/>}< br/> string name; <br/> Public string name <br/>{< br/> get {return name ;} <br/> set {name = value ;}< br/>}< br/> string sex; <br/> Public String sex <br/>{< br/> get {return sex ;}< br/> set {sex = value ;} <br/>}< br/> int age; <br/> Public int age <br/>{< br/> get {return age ;} <br/> set {age = value ;}< br/>}< br/>}

Subclass childclass:

Using system; <br/> using system. collections. generic; <br/> using system. LINQ; <br/> using system. text; <br/> namespace objectstruct <br/>{< br/> class childclass: baseclass <br/>{< br/> string grade; <br/> Public String Grade <br/>{< br/> get {return grade ;}< br/> set {grade = value ;} <br/>}< br/> Public childclass () <br/>{</P> <p >}< br/> Public childclass (string name, string sex, int age, string grade) <br/>: Base (name, sex, age) <br/>{< br/> This. grade = Grade; <br/>}</P> <p >}< br/>}

Running result:

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.