Home  >  Article  >  Backend Development  >  Example introduction and application of CTS (common type system)

Example introduction and application of CTS (common type system)

零下一度
零下一度Original
2017-06-23 16:12:061902browse
CTS (common type system)
The common type system stipulates that a type can contain zero or more members, as follows:
Field (Field):
Data variables that are part of the object's state. Fields are distinguished by name and type
Method:
A function that performs operations on an object, usually changing the object's state. A method has a name, a signature, and one or more modifiers. The signature specifies the number of parameters (and their order); parameter type: whether the method has a return value. If there is a return value, also specify the return value type
Property (prolerty):
To the caller, properties look like fields. But to the implementer of the type, the property appears to be a method (or two methods). Properties allow validation of input parameters and object state before accessing the value, and or calculating a value only when necessary. Properties also allow users of types to adopt a simplified syntax. Finally, properties allow the creation of read-only or write-only fields
Events:
Events implement a notification mechanism between the object and other related objects. For example, using an event provided by a button, other objects can be notified after the button is clicked
At the same time, CTS also specifies visibility rules and access rules for type members. For example, if the type is marked As public, any assembly can see and access the type. However, if it is marked as assembly (using internal modification in C#), only code in the same assembly can see and access the type. Therefore, using the rules set by CTS, the assembly establishes a visual boundary for a type, and the CLR also enforces These rules are implemented:
private:
members can only be accessed by other members of the same type;
protected:
members can be accessed by derived classes Access regardless of whether those types are in the same assembly.
internal:
Members can be accessed by any code in the same assembly
protected internal:
Members can be accessed by derived types in any assembly , members can also be accessed by any type in the same assembly
public
Members can be accessed by any code in any assembly

The above is the detailed content of Example introduction and application of CTS (common type system). For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn