What is C # managed code?
Managed code is actually the intermediate language (IL) code Managed. After the code is written, the compiler compiles the code into the intermediate language (IL) instead of the machine code that runs directly on your computer. The assembly (Assembly) file is responsible for encapsulating the intermediate language, and the assembly contains all the metadata that describes the method, class, and property that was created.
Managed code runs in the common language runtime (CLR). This runtime provides a variety of services for running code, and in general, the common language runtime can load and validate assemblies to ensure the correctness of intermediate languages. When some methods are called, the common language runtime compiles the specific method into a machine code that is appropriate for the local computer to run, and caches the compiled machine code for the next call. This process is the immediate compilation.
Note: The program is actually "hosted" in the common language runtime. As assemblies run, the common language runtime continuously provides services such as memory management, security management, thread management, and so on.
Summary: Managed code is code that is executed by the common language runtime (CLR), not directly by the operating system (Managed). Managed code can also invoke the CLR's runtime services and features, such as GC, type checking, security support, and so on. These services and features provide a unified, managed code application behavior that is independent of the development language.
The original text goes to: http://www.cnblogs.com/iamscree/articles/2363096.html
What is C # unmanaged code?
Unmanaged code is the machine code that compiles directly to the target computer, which can only be run on the computer that compiles the code, or on a computer that has the same processor or almost the same processor.
Unmanaged code cannot enjoy some of the services provided by the common language runtime, such as memory management, security management, and so on. If unmanaged code requires services such as memory management, it must explicitly invoke the interface of the operating system, and typically unmanaged code calls the APIs provided by the Windows SDK for memory management. An unmanaged program can also obtain operating system services by calling the COM interface. Note: C # Unlike other programming languages of the Visual Studio platform, C # can create managed programs and unmanaged programs. When you create a project that chooses a project type whose name begins with Mfc,atl or WIN32, the project produces an unmanaged program.
Summary: Unmanaged code, unmanaged code, is not executed by the CLR common language runtime, but rather directly by the operating system.
The original text goes to: http://zhidao.baidu.com/link?url= Bv1t7hfmssfuua1k5vyxn-dpgsw5-1j4tzv5ue9xmg4glsnrqks73ky5uuqg5ux4uyfpkbs0pueqw9bofx_ng3atxzajya1fflatx2yr9xk
What is C # managed code? What is unmanaged code?