In this section, we will understand the difference between managed and unmanaged code. Recall that we also studied this in Chapter 1, Learning the Basics of C#. Therefore, for a quick recap, we will just revise the concepts that we covered there.
These concepts apply not just to the C# language, they are also relevant to all languages written in the .NET Framework. The following are some of the differences between managed and unmanaged code:
- Managed code is executed by the Common Language Runtime (CLR). Due to this, the code is independent of the underlying OS. On the other hand, unmanaged code is code that is executed by the OS directly.
- In the case of managed code, the code is independent of the underlying framework or the OS. CLR compiles the code into an Intermediate Language (IL) code, which is then compiled to machine code. IL code consists...