C # Seal

Source: Internet
Author: User

 

You can declare a class as a sealed class. The method is to include keywords in the class definition.SealedPlace in keywordsClass. For example:

Public sealed Class D

{

// Class members here.

}

the sealing class cannot be used as the base class. Therefore, it cannot be an abstract class. The seal class is mainly used to prevent derivation. Since the seal class is never used as the base class, some runtime optimization can make the call to the seal class members slightly faster.

the class member, method, field, attribute, or event on the derived class that overwrites the Virtual Member of the base class can be declared as a seal member. When used in a later derived class, this will cancel the virtual effect of the member. The method is to sealed keyword placement override before the keyword. Example:

Public Class D: c

{

Public sealed override void dowork (){}

}

 

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.