The encapsulated method signature (called a delegate) implements type-safe event notification.
The delegate type indicates a reference to a method with a specific parameter list and return type. Through delegation, we can assign methods as entities to variables and pass them as parameters. Delegation is similar to the concept of function pointers in some other languages, but unlike function pointers, delegation is object-oriented and type-safe.
Property to act as an accessor for private member variables.
Attribute provides declarative metadata about the runtime type.
C #2.0 introduces several language extensions, including generic, anonymous method, iterator, and partial type) and nullable type ).
· Generics enable parameterization of classes, structures, interfaces, delegates, and methods based on the data types they store and operate on. Generics are useful because they provide stronger type checks during compilation, reduce Explicit conversions between data types, and perform type checks during boxing and runtime.
· Where the delegate value is required, the anonymous method allows code blocks to be written in "inline" mode. The anonymous method is similar to the lambda function in the lisp programming language. C #2.0 supports creating "closure". The anonymous method can access outer local variables and parameters.
· The iterator is a method for executing incremental calculations and generating a series of values. The iterator allows the type to easily specify the way the foreach statement cyclically accesses its elements.
· The Division type allows you to divide classes, structures, and interfaces into multiple parts and store them in different source files for development and maintenance. In addition, the Division type allows you to separate the computer-generated and user-written types, so that you can easily expand the code generated by the tool.
· An empty type indicates a value that may be unknown. An empty type supports all values of its basic type and an additional null state. Any value type can be used as the basic type of the null type. The null type supports conversions and operators of the same basic type as SQL, and also supports null propagation similar to SQL.
Accessibility |
Description |
Public |
Unrestricted access |
Protected |
Access is limited to this class and classes derived from this class |
Internal |
Access to this program only |
Protected internal |
Access is limited to this program and classes derived from this class |
Private |
Access is limited |
Interface(Interface)Defines a protocol that can be implemented by classes and structures
The string keyword is only the alias of the pre-defined class system. String.
The concept of packing and unpacking is the core of the C # type system. It builds a bridge between value-type and reference-type, so that any value-type value can be converted to an object type value, which in turn can be converted. Packing and unpacking enable us to examine the type system in a unified manner, and any type of value can be processed by object.