C # 's understanding of managed and unmanaged code

Source: Internet
Author: User

Understanding the CLR (Common Language Runtime) is the prerequisite to understand managed and unmanaged code

The. Net Framework is made up of two separate and interrelated parts: The CLR and the class library, the CLR is the service it provides to us, and the class library is the function it implements.
. NET most of the features----garbage collection, versioning, thread management, etc., all using the services provided by the CLR

When you compile the source code for the. NET framework, the resulting target code is not a machine instruction that the CPU can recognize, but rather a new language called "Microsoft Intermediate Language (MSIL, or code abbreviated as IL)". The CLR provides a real-time compiler,
Used to compile IL code into native machine code. In this way, the CLR can make the code portable because. NET application's source code must be compiled into IL code that can run on any platform that provides CLR services. From the perspective of the CLR,
All languages are equal, as long as there is a compiler that can generate IL code, which ensures interoperability of all languages.
Managed code-Managed Code

Code that is executed by the common language runtime (CLR) environment, not directly by the operating system. Managed code applications can obtain common language runtime services, such as automatic garbage collection, runtime type checking, and security support.
These services help provide platform-and language-independent, unified managed-code application behavior.

Unmanaged code-Unmanaged

Code that is executed directly by the operating system outside of the common language runtime environment. Unmanaged code must provide its own garbage collection, type checking, security support, and other services, unlike managed code, which obtains these services from the common language runtime.

C # 's understanding of managed and unmanaged code

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.