Managed code (
managed code) is
C# code.
C# the code runs under the control of
CLR (Common Language Runtime).
That is, in
C# we create an object by calling
new, and
CLR (Common Language Runtime) will automatically delete the object from memory when necessary.
Unmanaged code (
unmanaged code) is
C++ code.
In
C++ there are pointers, i.e. when we create an object by calling
new, the pointer points to this object, and then by the pointer we ourselves must remove the object from memory by calling
delete.
In
C++ we can change the pointer to a piece of memory that was not allocated, and if we try to delete it, then our C++ application will be closed by the Windows system.
That is,
C++ the code is compiled into an assembler and executed directly with the
Windows system.
C# the code is compiled in
intermediate code IL (Intermediate Language) and runs inside
CLR (Common Language Runtime).
CLR (Common Language Runtime) is executed directly with the
Windows system.
CLR (Common Language Runtime) controls memory disposal and there are no pointers, so
C# code is called managed code
managed code.