This book describes C # language in great detail. I will sort out the important content into terms to be forgotten.
1.
. Net
It consists of three parts:
CLR
, Encoding tools and
Bcl
.
CLR
Responsible for memory management, code security verification, code execution, and garbage collection.
. Net
Provides platform calling (
P/invoke
)
,
Call allowed
Windows API
And
Com
Interactive operation.
2.
. Net
Developers do not need to understand
Com
Knowledge, such
Iunknown
Interface, Type Library, reference count, registry and
Hresult (COM
Use
Hresult)
The data type returns the runtime error code, while
. Net
Not used
Hresult
Because all running errors will cause exceptions.
3.
. Net
The language compiler accepts the source code file, and the output file is the assembly. The code in the Assembly is not local code,
Cel
. Inclusion in programs
Cel
The Type metadata used by the program and the metadata referenced by other assembly.
4.
CLR
At runtime, first check the security features of the assembly, allocate space in the memory, and then call
Code delivery
JIT
. In the Assembly
Cel
It is called only when it is called.
JIT
Compile the code at the cost and then cache it for execution in later programs. That is, the code that is not called will not be compiled at the cost, the called code is compiled only once. Once
Cel
Locally compiled code,
CLR
It is managed at runtime, such as releasing memory, checking the array boundary, checking the parameter type, and managing exceptions.
5.
Run in
CLR
And
CLR
The controlled code is called managed code, and vice versa.
6.
CLI (
Basic Structure of Public languages
)
Is a group of specifications that describe the system architecture, rules, and conventions.
. Include
CTS:
Defines a rich set of built-in types and defines the detailed features of each type.
,
And all supported
. Net
The types provided by the language are usually mapped
CTS
A special subset of the built-in type set defined in;
CLS
: Detailed support
. Net
Language rules, attributes, and behaviors. The subject includes data types, class structures, and parameter transmission.
7.
Any
. Net
The platform as the target language must establish its data type and
CTS
. All
. Net
Languages share this type of system to achieve seamless interoperability between them. This solution provides inheritance between languages.
8.
Because
CLS
Yes
CTS
Subset
,
This means that a language feature may be consistent
CTS
Standard, but exceeds
CLS
Such:
C #
Supports the unsigned numeric type.
CTS
Test,
CLS
But only recognizes the signed numeric type. Therefore, if you use
C #
You may not be able to use a language that does not support the unsigned type (for example
VB. NET
) Designed components implement interoperability, but it is not impossible. In fact, users can safely implement
Private
Member components,
CLS
Compatibility issues. However, if you need
. Net
Language interoperability
Public
The member must fully comply
CLS
Specification.
9.
@
The characters can only be placed at the top of the identifier. The identifier has two naming styles:
Pascal
Style, such:
Cardeck
, We recommend that you use the type name and member name;
Camel
Style, such:
Totalcyclecount
We recommend that you use it for local variables and method parameters.
10.
Two common conventions: Field
The name must start with an underscore:
Example
Or use
M _
Start:
M_example
.
11.
In
C #
You can use any placeholder and any number of values. values can be used in any order, and values can be replaced by any number of times in the format string. For example:
Console. writeline ("three integers are {1}, {0}, {1}.", 3, 6 );
The output is
Three
Integers are 6, 3, 6.
12.
The placeholder cannot reference a location other than the value list.
If this is done, no compilation error will be generated, but a runtime error will be generated.
(
Exception
)
.