Virtual methods and abstract methods in C # (thirteenth day)

Source: Internet
Author: User

Today I learned a lot in the cloud and college, I can only summarize the virtual method and abstract application in C # this time.

Theory:

• Virtual modification is called virtual method• Virtual methods can be overridden by the override keyword in subclasses• Common virtual methods: ToString () Equals Real:

Defines a people parent class, including Name,gender,age, and a Peohi virtual method that defines two subclass teacher, including year,salary two properties and a Peohi method; subclass student, Includes Stadynum and a Peohi method.

Define subclass Teacher (student subclass is the same as teacher definition method, not described here)

Output in the main function

Output results

Abstract method, define a parent class person, and subclass Chinese

Well, I'll write about it today, and we'll go on with it next time. Come on!

Virtual methods and abstract methods in C # (thirteenth day)

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.