CLR notes: 6. Types and Membership Basics

Source: Internet
Author: User
Tags command line static class

1.Class visibility has public and internal two, public is visible to all assemblies, and internal is visible only to the assembly in which it resides. The default is public.

2. Friend assembly,

Using friend assembly, you can implement unit testing without using reflection technology.

The book is about compiling according to the command line.

I tested it with the VS2005 solution, as follows:

3. Accessibility of Members

Members are private by default, and members of the interface type are public.

When a subclass overrides a member of the parent class, the original member has the same accessibility--c# as the overriding member; the CLR's constraint is that the overriding member's accessibility cannot be lower.

The CLR and C # are not the same, such as tables:

CLR terminology C # Terminology
Private Private
Family Protected
Family and Assembly does not support
Assembly Internal
Family or Assembly protected internal
Public Public

4. Static Class

Static can only be used for class and cannot be used for struct because the CLR requires that the value be instantiated and cannot control the instantiation process.

C # constraints on static classes:

Static classes must derive directly from System.Object

Static classes cannot implement any interfaces

Static classes can only define static members: Fields, methods, properties, events

Static classes cannot be used as: fields, methods, arguments, local variables.

In MSIL, ctor is not generated for static classes, which are marked as abstract and sealed

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.