Static class (C #),

Source: Internet
Author: User

Static class (C #),

Basic Introduction:

Class can be declared as static to indicate that it only contains static members. You cannot use the new keyword to create a static class instance. When a static class loads a program or namespace containing the class, it is automatically loaded by the. NET Framework Common Language Runtime Library (CLR; specifically: C # language.

Advantages:

The advantage of using static classes is that the compiler can perform checks to prevent accidental addition of instance members. The compiler will never create such instances. Static classes are sealed and therefore cannot be inherited. A static class cannot contain constructor, but can still declare a static constructor to assign an initial value or set a static state. Note: The static class cannot have an instance constructor. Static classes cannot have any instance members. Static classes cannot use abstract or sealed modifiers. Static classes are inherited from the System. Object root class by default, and cannot explicitly specify any other base classes. Static classes cannot specify any interface implementation. A static class member cannot have a protected or protected internal access protection modifier.

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.