This website includes Education Information like a programming language, job interview question, general knowledge.mathematics

Education log

PageNavi Results No.

Ads

Friday, November 1, 2024

what is managed and unmanaged code in c#

 what is managed and unmanaged code in c#


In C#, managed code is code that runs in a runtime environment, while unmanaged code runs directly on the hardware



1. Managed code

Runs in the .NET framework's CLR (Common Language Runtime). It's written in high-level languages like C#, Visual Basic, or F#, and is compiled into Intermediate Language (IL) code. The CLR then compiles and executes the IL into machine code. Managed code offers automatic memory management, high-level abstractions, and platform abstraction. It also provides security protection against common errors like memory leaks and buffer overflows.


2. Unmanaged code

Runs directly on the hardware, giving the programmer more control but requiring manual memory and pointers management. Unmanaged code is also known as unsafe code. Examples of unmanaged code include COM components, ActiveX interfaces, and Windows API functions. 



No comments:

Post a Comment