C # Learning Notes-day one, relationship between C # and the. NET Framework
The C # compiler is dedicated to. NET, which means that all code written in C # always runs with the. NET Framework. So for the C # language, there are two possible conclusions:
1) The architecture and methodology of C # reflects. NET basic methodology.
2) In many cases, the language-specific features of C # depend on. NET functionality, or depends on the. NET's base class.
Two. NET compilation process
1) Compile the source code into Microsoft intermediate Language Il (intermediate Language);
2) The common language runtime CLR compiles IL into platform-specific code.
Third, intermediate language IL
IL (intermediate Language) is Microsoft. NET platform, a middle language derived from the The compilers of various high-level languages (such as c#,vb,f#) on the net platform convert their code to IL. , which contains the. NET platform, such as "Paradigm", "Class", "Interface", "module", "Property" and so on. It is worth noting that the various high-level languages themselves may not have these "concepts" in them, such as Ironscheme is a scheme language implementation on the. NET platform, where none of the il--mentioned above is or is. The nouns on the net platform. Il itself does not know what kind of high-level language they are transformed into, which language features, and IL does not care at all. Through the intermediate language IL, platform independence can be achieved.
Iv. JIT Compilation
Instead of compiling the entire application one at a time, the JIT compiler compiles only the part of the code it calls. Once the code has been compiled once, the resulting local executable is stored until the application is exited, so that it does not need to be recompiled the next time the code is executed.
V. Managed code
The code that the common language runtime environment executes, not the code that the operating system executes.
VI. Finally
When an exception is thrown, it changes the execution process of the program. Therefore, there is no guarantee that after the end of a statement, the statement after it will be executed, in C # This problem can be solved with a finally.
To ensure that a statement is always able to execute (whether or not an exception is thrown), the statement needs to be placed in a finally block, either immediately after the try block or immediately after the last catch handler after the try block. Whenever a program enters a try block associated with a finally block, the finally block will always run – even if an exception occurs.
C # Learning notes-First day