What is difference between unsafe code and unmanaged code in C#?
Unsafe code in C# allows the use of pointers. In the context of the CLR, there is no unmanaged code in C#.
managed code runs under supervision of the CLR (Common Language Runtime). This is responsible for things like memory management and garbage collection.
So unmanaged simply runs outside of the context of the CLR. unsafe is kind of "in between" managed and unmanaged. unsafe still runs under the CLR, but it will let you access memory directly through pointers.