Home > Article > Backend Development > C# basic knowledge compilation: .NET knowledge
1. What is .NET Framework
The so-called .NET FrameWork is a platform, and its purpose is for cross-operating system programming. It contains many modules, such as Windows application components, Web development modules, etc. Different operating systems support some of these modules according to their own characteristics. NET framework is a programming platform that runs on a virtual machine. It is based on the Common Language Runtime and supports the development of multiple languages (C#, VB.NET, C++, etc.). Can develop desktop applications (WinForm, WPF, SilverLight, Office), Web applications (Asp.NET, ASP.NET
MVC, SilverLight), Windows Service, and mobile embedded development. Currently commonly used versions are: 2.0, 3.0, 3.5, 4.0;
2. Several concepts in .NET
(1), CLR concept?
Details: CLR is the common language runtime. (Common Language Runtime) is also a runtime environment like the Java virtual machine. It is responsible for resource management (memory allocation and garbage collection), and ensures that applications and the underlying operating system necessary separation.
(2) What are the advantages of managed code?
Details: //m.sbmmt.com/
(3), the true meaning and form of language interoperability?
Details: A class written in one language should be able to inherit a class written in another language
A class can contain instances of another class, regardless of what language they are written in. A Objects should be able to directly call methods of objects written in other languages
Objects (or object references) should be passed between methods
When calling methods between different languages, they should be able to be used in the debugger Debugging the calls of these methods, that is, debugging codes written in different languages
(4). In .NET, what is the program compilation process?
Details: //m.sbmmt.com/
(5) What are the main features of intermediate language?
Can be compiled by different compilers in real time and run on different structures, eliminating language disputes. Intermediate language or high-level language.
(6) What is the conceptual distinction between dynamic language and static language, strongly typed definition language and weakly typed definition language?
Dynamically typed language: A language that checks data types during runtime.
Static typed language: Data types are checked during compilation. Strongly typed definition language: a language that forces data type definition.
Weakly typed definition language: a language in which data types can be ignored. It is the opposite of a strongly typed definition language, in which a variable can be assigned values of different data types.
(7) Compiled type and interpreted type (refer to the blog)
Let’s look at the compiled type first. In fact, it is the same as assembly language: there is also a program responsible for translation. Our source code is converted to generate corresponding executable code. To put it more professionally, this process is called compilation, and the program responsible for compilation is naturally called a compiler. If the program code we write is contained in a source file, then usually an executable file will be generated directly after compilation, and we can run it directly. But for a more complex project, in order to facilitate management, we usually disperse the code in various source files and organize it as different modules. At this time, when compiling each file, an object file will be generated instead of the executable file mentioned earlier. Generally, the compilation of a source file will correspond to a target file. The content in these target files is basically executable code, but since it is only the entire project
part, so we can't run it directly yet. After all the source files are compiled, we can finally "package" these semi-finished target files into an executable file. This work is completed by another program, because this process seems to include the executable code. The target files are connected and assembled, so it is also called a link, and the program responsible for linking is called...it is called a linker. In addition to linking target files, the linker may also have various resources, such as icon files, sound files, etc., and is also responsible for removing redundant duplicate codes between target files. After the link is completed, we can generally get the executable file we want.
Look at the explanation type again. "Compilation" and "interpretation" do both mean "translation", but the difference lies in the timing of translation. For example: If you plan to read a foreign book and you don’t know the foreign language, then you can find a translator and give him enough time to translate the entire book from beginning to end, and then translate the book The native language version is given to you to read; or, you can immediately ask the translator to assist you in reading, and let him translate for you sentence by sentence. If you want to go back to a certain chapter, he will have to translate it for you again. Of the two methods, the former is equivalent to the compiled type we just mentioned: converting all the code into machine language at once and then writing it into an executable file; and the latter is equivalent to the interpreted type we are talking about: just before the program runs , there is only a source program but no executable program; and every time the program executes a certain instruction of the source program, there will be a shell program called an interpreter to convert the source code into binary code for execution. In short, It means constant interpretation, execution, interpretation, execution... Therefore, interpreted programs are inseparable from interpreting programs. For example, early BASIC is a classic interpreted language. To execute a BASIC program, you have to enter the BASIC environment, and then you can load the program source file and run it. In an interpreted program, since the program always appears in the form of source code, transplantation is almost no problem as long as there is a corresponding interpreter. Although the source code of compiled programs can also be transplanted, the prerequisite is that they must be compiled separately for different systems.
For complex projects, it is indeed a huge time-consuming task, and it is very likely that the source code still needs to be modified in some details. Moreover, interpreted programs save the compilation step, and are very convenient for modification and debugging. They can be run immediately after editing. Unlike compiled programs, you do not have to wait patiently for the long Compiling...Linking...compilation every time you make small changes. linking process. However, everything has pros and cons. Since interpreted programs put the compilation process into the execution process, this determines that interpreted programs are destined to be much slower than compiled programs. It is not surprising that the speed difference is hundreds of times. of.
Compiled type and interpreted type, both have advantages and disadvantages. The former has fast program execution speed and lower system requirements under the same conditions. Therefore, it is used when developing operating systems, large-scale applications, database systems, etc., such as C/C++, Pascal/Object Pascal (Delphi), VB and other basic programs. All can be regarded as compiled languages, while some programs such as web scripts, server scripts and auxiliary development interfaces that do not have high speed requirements and have certain requirements for compatibility between different system platforms usually use interpreted languages, such as Java and JavaScript. , VBScript, Perl, Python, etc.
But since compiled and interpreted languages have their own advantages and disadvantages and are in opposition to each other, a number of emerging languages tend to compromise the two. For example, although the Java language is closer to the characteristics of an interpreted language, it does not have the characteristics of an interpreted language before execution. It has been precompiled in advance, and the generated code is an intermediary code between the machine code and the Java source code. When running, it is interpreted and executed by the JVM (Java's virtual machine platform, which can be regarded as an interpreter). It not only retains the high abstraction and portability characteristics of the source code, but also has completed most of the pre-compilation of the source code, so it executes much faster than "purely interpreted" programs. For languages like VB6 (or previous versions) and C#, although on the surface they generate .exe executable program files, what is actually generated after VB6 is compiled is also an intermediate code, but the compiler inserts a paragraph in front of it. Automatically call an external
The code of the internal interpreter (this interpreter is independent of the program written by the user and is stored in a DLL file of the system. All executable programs compiled with VB6 must use it) to interpret and execute the actual program body. C# (and other .net language compilers) generates .net target code, which is actually executed by the .net interpretation system (just like JVM, it is also a virtual machine platform). Of course, the .net target code is already quite "low-level" and is closer to machine language, so it is still regarded as a compiled language, and its portability is not as powerful as Java claims. Java claims to be "compile once, execute everywhere". And .net is "encode once, compile everywhere". In short, with the continuous development of design technology and hardware, compiled and interpreted types
The boundaries between approaches are becoming increasingly blurred.
The above is the compilation of C# basic knowledge: .NET knowledge. For more related content, please pay attention to the PHP Chinese website (m.sbmmt.com)!