C # sealed keywords

Source: Internet
Author: User

SealedModifiers can be applied to classes, instance methods, and attributes.
The class modified by sealed is a sealed class, which cannot be inherited.
The method modified by sealed is the sealing method. The sealing method will override the methods in the base class, but it cannot be further rewritten in any derived class. When applied to methods or attributes, the sealed modifier must always be used with override.

Use the sealed modifier in the class declaration to prevent this class from being inherited. For example:
Sealed class sealedclass {public int X; Public int y ;}

When sealed modifies a class, the class cannot be abstract, that is, it cannot be both an abstract class and a sealed class.
In addition,Note that the structure (struct) is implicitly sealed. Therefore, they cannot be inherited.

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.