C # interfaces and abstract classes

Source: Internet
Author: User

(1) Abstract classes are defined using the abstract keyword, and the interfaces are defined using the interface keyword, and they cannot be instantiated.

(2) Abstract classes can contain virtual methods, non-abstract methods, static members; The interface cannot include virtual methods, any static members

And the interface can only define methods, cannot implement methods, the specific time of the method should be done by the class.

(3) Abstract classes cannot implement multiple inheritance, interfaces can inherit more, strictly speaking, the class-inheriting interface should be the class implementation interface.

(4) Abstract class is the abstraction of an object, and the relationship between the class and the abstract class that inherits from the abstract class is the relationship of the class.

Just represents the implementation class has an interface declaration method, is a can-do relationship, so the interface after the general with the Able field indicates I can do;

C # interfaces and abstract classes

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.