Chapter VII Type Member and Its Access Limited
First, the possible composition of type members:
ü ???????? constant, always static unstractified
ü ???????? field, divided into two kinds of static and instance fields
ü ???????? instance constructor, initialization instance object
ü ???????? Type constructor, initialization type static field
ü ???????? method, divided into two kinds of static and instance methods
ü ???????? Overload operator, not part of CLS, because not all languages support
ü ???????? Conversion operator, not part of the CLS, some languages are not supported
ü ???????? attribute, divide static and instance properties
ü ???????? Event, divided into two kinds of static and instance events
ü ???????? type
?
Second, access limit modifier: [only lists in C #]
C # terminology
description
Private only the type (or nested type thereof) access protected only the type (or nested type) or inheritance type Access INTERNAL can only be locked programs Access protected internal can only be The defined type (or nested type), derived type, and access to the same app to access any type of access to any assembly.
Note: 1. The default access method is internal
?????? 2, only one modifier described above can be selected, and two cannot be specified.
?
Third, type predefined characteristics:
C # terminology
description
Abstract cannot be instantiated, can be used as a base type SeaED cannot be used as a base type
Note: The above-mentioned qualifier cannot be used simultaneously, and the PRIVATE constructor can be provided to Sealed modified to achieve the purpose of "not being instantiated and cannot be inherited".
?
Fourth, the field predefined feature:
C # terminology
description
The Static field is only assigned in the constructor.
Note: The difference between constants and static read-only fields will be detailed in Chapter 8
?
V. Method predefined characteristics
C # terminology
description
Static Type Method, you cannot access the instance or type field, you can access the type method or type field default (called instance) instance method, you can access an instance method or field, or you can access the type method or field virtual polymorphism. The final implementation of the Total Toner Inheritance Chain is only used for imaginary methods. The hidden class type method is used to implement Override is only for imaginary methods. Display declaration rewrite category method ABSTRACT is only used for imaginary methods, and the derived class must provide and the abstract method The realization of the matching, the type of abstract method is an abstract type Sealed is only used for imaginary methods, and the derived class cannot override the method.
Note: Sealed and Abstract cannot be used at the same time