QuiltInternalModifierOnlyUsed in this Assembly (current project.
QuiltProtected internalThe modified attributes/methods can beDerived classUse
For example, app1 and app2.
App1 is the startup project, while app2 is only a class library
/* Project app2 */
Namespace app2
{
Internal class cinternal // This class can only be used in app2 (the entire class is internal, equivalent to all attributes are also internal ){
Public int A; // only app2 can be used.
Internal int B; // same as above, only available in app2
}
Public class vinternal // This class can be used in app1 (as long as app2 is referenced), but internal-modified attributes/methods in this class cannot be used in other projects other than app2 {
Internal int A; // can only be used in app2
Protected internal int B; // It Can Be Used in app2. it cannot be used directly in app1, but it can be used by classes inherited from this class in app1.
Public int C; // use protected internal void display () in app1 app2, which cannot be used directly in app1, however, it can be used by classes inherited from this class in app1. {Console. writeline ("Hello protected internal ");}}
} // Namespace app2
/* Project app1 */
Using app2;
Namespace app1 {
Class app1 () {app2.cinternal internalclass = new app2.cinternal ();//!!! Error !!! -Cinternal is modified by internal and can only be used in app2.
& Nbsp; app2.vinternal internalvar = new app2.vinternal (); // OK-vinternal is public and can be used anywhere
& Nbsp; internalvar. A = 100 ;//!!! Error !!! -Modified by internal, which can only be used in app2
& Nbsp; internalvar. B = 100 ;//!!! Error !!! -It is modified by protected internal and cannot be used directly in external projects.
& Nbsp; internalvar. c = 100; // OK
Internalvar. Display ();//!!! Error !!! -It is modified by protected internal and cannot be used directly in external projects.
} // Classapp1
& Nbsp; Class inheritfrominternal: app2.vinternal // inherits the vinternal, so you can use the attribute {base. A = 100 ;//!!! Error !!! -Attributes modified to internal can only be used in app2.
Base. B = 100; // OK-attributes modified as protected internal can be used by the derived class.
Base. Display (); // OK-attributes modified to protected internal can be used by the derived class.
} // Classinheritfrominternal
} // Namespace app1