C # differences between abstract classes and interfaces

Source: Internet
Author: User

1. Abstract: in addition to being able to define abstract members, it also provides specific implementation details of some members. The interface can only contain a set of abstract member definitions.

 

2. abstract classes and interfaces support polymorphism. The difference is that to realize polymorphism, an abstract class must have a subclass that inherits it, rather than a class of the same level or higher level. The interface supports polymorphism and has no limitations on hierarchy inheritance. As long as a group of classes implement interfaces, these classes reflect polymorphism. An example is: system. array, system. String has no parent-child relationship, but they all implement the icloneable interface.

 

3. abstract class derived types must be abstract members while inheriting the parent class members, which may not be meaningful in some cases. Interfaces provide more flexible plug-in Processing Methods: interfaces can be implemented at any inheritance level when necessary.

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.