ASP. NET learning notes (13) sealed, new, virtual, abstract, and override

Source: Internet
Author: User

1. The sealed sealing class cannot be inherited. The sealing method can override the methods in the base class, but cannot be overwritten in any subclass.
It must always be used with override when applied to methods and attributes.

2. new indicates that the member inherited from the base class is hidden. If new is not used, a warning is displayed.

3. virtual Methods and attributes are called virtual members. By default, methods are non-virtual and non-virtual methods cannot be rewritten.
1. virtual cannot be used for static attributes.
2. Rewrite the virtual inheritance attribute in the subclass by using override

4. abstract indicates that this class can only be the base class of other classes.

Abstract class:
1. It cannot be instantiated.
2. Non-Abstract subclasses must include all abstract methods of the base class and the implementation of the abstract accessors.

Abstract method:
1. the abstract method is an implicit virtual method.
2. Only abstract methods can be used in abstract classes.
3. the Declaration does not provide implementation, usually ended with a semicolon, for example, public abstract void MyMethod ();
4. abstract methods cannot be modified using static or virtual


5. override is used to override abstract and virtual modified members in the base class.


By: dxh_0829

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.