What is managed or unmanaged code?

Asked 07-Dec-2019
Viewed 2661 times

1 Answer


0

Difference between Managed and Unmanaged code in .NET

The managed code is the code which is managed by the CLR(Common Language Runtime) in DotNet Framework. Whereas the Unmanaged code is the code which is directly executed by the operating system. Here the below are some important differences between the Managed code and Unmanaged code:

What is managed or unmanaged code?

Example :-

static unsafe void Main(string[] args) {

   int var = 20;
   int* p = &var;
   Console.WriteLine("Data is: {0} ", var);
   Console.WriteLine("Address is: {0}", (int)p);
   Console.ReadKey();
}