The Difference Between Managed and Unmanaged Code in .Net

Managed Code

In simple terms the code which is executed by CLR (Common Language Runtime) is called Managed Code, any application which is developed in .Net framework is going to work under CLR, the CLR internally uses the Garbage Collector to clear the unused memory and also used the other functionalities like CTS, CAS etc.

If we need to execute the Managed code application we must need to install .Net frame work as we need CLR to execute this code.

Managed Code

Unmanaged Code

The unmanaged code is basically developed using other languages (other than .Net Framework), so it uses its own language runtime to execute the applications. The application runtime will take care of its memory management, security etc...

Even if we do not install .Net framework the unmanaged code will work properly as it is not depending on the CLR.

We can also run unmanaged code using managed code by using commands, but even if we run the unmanaged application using .Net code the CLR is not having control to run that application, the application uses its own runtime to execute.

unManaged Code

Hope this article willhelp in understating the difference between managed and unmanaged code, please leave your comments for further improvements.