Home > Net >  Access modifiers and what is the assembly
Access modifiers and what is the assembly

Time:09-18

To access attributes of the class have public, private, protect, innertal, protect internal. Including internal only in the same assembly file, internal type or member is accessible, can use this to continue the assembly under the case,

The View Code
You said that the compiler can pass? Based better students, obviously, if can be seen without a compiler, this is a grammatical errors, as a class attribute, attribute of accessibility not higher than the type of accessibility,

Find the MSDN found http://msdn.microsoft.com/zh-cn/library/k3677y81 (v=vs. 100) is here:

Assembly is formed based on the.net application deployment, version control, reuse, activate the scope and the basic unit of the security permissions, the assembly to the executable (.exe) file or a dynamic link library (DLL) file form, is the.net Framework to generate blocks, they provide the common language runtime to realize the information they need to know type, the assembly can be as a logical function unit and to work together to generate a collection of types and resources,

Assemblies can be divided into, the public private assemblies, assemblies and Microsoft offer we use the framework of the System is public assemblies, such as private assemblies can be said to be our new library, why is there this distinction, because in general a set of program can only be one process domain loaded, if you want to more fields to load the same assembly process, so only the assembly into public assemblies, we write the DLL can also join the public assemblies (but there must be a strong name), very simple, they can find, there is a very simple is the distinction between public assembly method, if you are quoting this DLL, the DLL has not been copied to the bin directory, that he is a public assembly (Microsoft and yourself to join the public assembly http://space.189works.com/space-uid-10034751.html in detail.





The following key included c # access modifier and various elements of access modifiers default

Can be defined in a namespace elements are: class (class), structure (struct), commissioned (delegate), interface (interface), the enumeration (enum)

MSDN: protected internal protected accessibility mean "or" internal, not protected "and" internal,

Our access modifier has a total of five levels

Public, private, protected, internal, protected internal

Namespace elements under the default access modifier (can be defined in a namespace elements are: class (class), structure (struct), commissioned (delegate), interface (interface), the enumeration (enum))

Namespaces can only be used under the two types of access modifiers public and internal, if there is no explicit access modifier to these elements, the modifier default as internal,

Public: any other of the same assembly code or reference the assembly of other assemblies can access the type or member,

Internal: any of the same assembly code can access the type or member, but other assemblies can not access,

Each type of the members of the default access modifier

The rest of the modifier is mainly aimed at inherit the language features, has inherited type two - class (class), and interfaces (interface), public, internal also can be used to type members,

Private: the same kind of code can access the type and structure and members,

Protected: the same class and the derived (inheritance) code can access the type and the members of the class,

Protected internal: same program any code or any other application of centralization of any derived class can access the type or member,

MSDN:

1.) accessibility of derived classes cannot be higher than the base type, in other words, there can be derived from the inner class A public class B, if allow this kind of situation, will make A public class, because all of A protected members or internal members can access from the derived class,

2.) member accessibility must not be higher than the containing type of accessibility,

3.) you can use any one of five types of access to declare class members (including nested classes and structures),

Interface (interface)

Interface members of the default to public access modifier, and cannot show use access modifiers,

Class (class)

Constructor default to private access modifiers,

Destructors cannot display use access modifier and default to private access modifiers,

Members of the class the default access modifiers for private;

Enumeration (enum)

Enumeration type members by default to public access modifier, and cannot display using modifiers,

Structure (struct)

Structure member by default for the private modifier,

Members of the structure member cannot be declared as protected, because the structure does not support inheritance,

A nested type

Nested types of access modifiers for private by default, and classes, the default access type of the structure of the membership,
  • Related