C # basic -- Initial. NET Framework

Source: Internet
Author: User

I. NET Framework meaning:

. NET Framework is a development platform created by Microsoft to develop applications. It can not only run on Windows operating systems, but also use Mono (it is.. NET Framework open-source version, including C # compiler) running on Linux and MacOS. an important reason for NET Framework is that it can integrate various operating systems ;.. NET Framework can also create different types of applications, such as Windows applications, Web applications, Web services, and other types of applications.

Ii. NET Framework content:

. NET Framework mainly contains a large code library, which is divided into multiple different modules and can be used according to the desired results. For example, A module contains components used by Windows for modules, a module contains network programming code blocks, and a module contains Web development code blocks. The purpose is that different operating systems use their own features, some or all of these modules are supported.

Part. the NET Framework library also defines some basic types, which are a type of data expression, specifying the most basic part (such as a 32-bit signed integer) for use. NET Framework performs interactive operations between various languages. This is called the Common Type System (CTS). In addition to this library ,. NET Framework also contains. NET Common Language Runtime (CLR), which is used for management.. NET Library.

3. Use NET Framework to write applications:

Writing applications using. NET Framework is to write code using the. NET code library (using any language that supports the Framework ).

For example, to execute C # code, you must convert them into a language that the target operating system can understand, that is, native code. This conversion is called the compiled code, which is executed by the compiler. However, under. NET Framework, this process involves two phases.

3.1, pencil, and JIT

Used in compilation. NET Framework library code, instead of immediately creating the Local Code dedicated to the operating system, but compiling the code into Common Intermediate Language (CER) code, these codes are not specifically used for an operating system, nor for C #. Other. NET languages, such as VB. NET, can also be compiled into this language in the first stage. When developing C # applications, this compilation step is completed by.

Obviously, to execute an application, more work must be done, which is a task of the Just-In-Time (JIT) compiler, it compiles the Server Load balancer into the local code dedicated to the operating system and the target server structure so that the operating system can execute applications, here, the compiler name Just-In-Time reflects the fact that the pencil code is compiled only when necessary. (The JIT compiler uses the pencil code, which is independent of computers, operating systems, and CPUs. There are currently several JIT compilers, each of which is used in different structures, therefore, you can always find a suitable compiler to create the required native code [Microsoft Intermediate Language (MSIL) or IL, MSIL is the original name of the pencil ]).

3.2 assembly

When compiling an application, the created cilcode is stored in a program concentration, and the library used by the program library to package executable Application Files (whose extension name is .exe) and other applications (whose extension is. dll), in addition to the contains, the Assembly also contains metadata (that is, the information of the data contained in the Assembly, also known as metadata) and optional resources (other data used by the pencil, for example, audio files and images), the metadata allows the assembly to be completely self-described, and the Assembly can be used without other information, that is, you will not be able to add the required data to the system registry.

3.3 hosting code

After the code is compiled into a pencil and compiled into the local code by using the JIT compiler, the CLR tasks are not completed yet, and you need to manage the ongoing use. NET Framework Code (this stage of code execution is usually called runtime), that is, the CLR manages applications, the method is to manage memory, handle security, and allow cross-language debugging. On the contrary, applications that are not controlled by CLR belong to an unmanaged type, such as C ++. However, in C #, only code that runs in a hosted environment can be compiled, use the managed function of CLR to make.. NET interacts with the operating system.

3.4. Garbage Collection

One of the most important functions of managed code is garbage collection. the. NET method ensures that the memory is completely released when the application no longer uses some memory. before the launch of NET, this work was mainly undertaken by programmers. Several simple errors in the code will allocate large blocks of memory to the wrong places, so that these memories are mysteriously missing, this means that the speed of the Computer slows down and eventually causes the system to crash );. NET garbage collection regularly checks the computer memory to delete unwanted content from it. It does not set time frames, and may perform thousands of checks within one second or several seconds, or check at any time.

Tip: Because this task is executed in unpredictable time, you must pay attention to this when designing the application. The code that requires a lot of memory to run should be consciously executed for such check, instead of waiting for garbage collection

3.5. Summarize the steps for creating a. NET application:

(1) Use a. NET compatible language (such as C #) to write application code;

(2) Compile the code into a pencil and store it in a program set;

(3) When executing code (if this is an executable file, it runs automatically or when other code uses it ), first, you must use the JIT compiler to compile the Code as the local code;

(4) run the local code and other applications or processes in the managed CLR environment;

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.