In this blog, I’m explaining about managed code and unmanaged code in C#.
1. Managed code is executed under the control of CLR (Common Language Runtime).
2. There is no explicit memory allocation and de-allocation.
3. There is no explicit call to the garbage collector.
Managed code= .NET Programs
Code that is directly executed by the operating system is known as unmanaged code or unsafe code.
Unsafe code is code which does not execute under full control CLR. It can cause some problems, therefore, each use must be marked as unsafe.
Fixed: In an unsafe context, the fixed keyword can be used to temporarily fix a variable so that its address may be found.
Right click on your project >>properties>> go to the build tab>> check unsafe code checkbox
unsafe static void Main(string args)
fixed (char* value = str)
char* ptr = value;
while(*ptr != '\0')