reprint [C #] virtual function (virtual), abstract function (abstraction) and interface differences

Source: Internet
Author: User

1.virtual: Allowed to be rewritten, but not mandatory. Provide its own implementation when declaring;
2.abstract: Mandatory overrides are required for its successors. The declaration does not provide its own implementation, the abstract class can not be instantiated;
3.interface: An interface is a protocol whose declared members (properties, methods, events, and indexers) must be implemented by its inherited classes. The interface cannot be instantiated directly.

The difference between a virtual method and an abstract method is that a virtual method provides its own implementation and does not enforce a subclass rewrite, whereas an abstract method does not provide its own implementation and enforces a subclass rewrite.

Abstract classes are similar to interfaces, but the ideas are different. An interface is a member of a public class, whereas an abstract class is an abstract class member that requires a subclass to inherit and implement.

Original address:

Http://www.cnblogs.com/staid/archive/2010/06/23/1763437.html

reprint [C #] virtual function (virtual), abstract function (abstraction) and interface differences

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.