C # Abstract class

Source: Internet
Author: User

Abstract class is always a class in my eyes, but unlike other classes, this class can only define the declaration of methods (function declaration, the specific function body or function implementation can also be defined elsewhere. However, an interface only defines a contract. This contract is just a form, and the actual contract process to be implemented is the form of contract (implement ), it needs to be implemented through a specific class. Therefore, an interface is just a convention. It is a data structure that is declared but not implemented.

Second, compared with a common class, an abstract class can be declared or contain specific implemented functions. A common class must contain both declarations and implementations. When using abstract classes, remember the following three points:

1. the abstract class must be [inherited]

2. abstract classes cannot be [sealed]

3. the abstract class cannot be [instantiated], meaning it cannot be new.

For details about the reason why it cannot be sealed, refer to the introduction of the seal class.

First, I posted my post on the 163 blog and copied it to myself.

Http://wanzegui325.blog.163.com/blog/static/3542295201012033937546

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.