What is unsafe/unmanaged code in C#?

CsharpProgrammingServer Side Programming

Applications that are not under the control of the CLR are unmanaged. The unsafe code or the unmanaged code is a code block that uses a pointer variable and allows pointer usage in unmanaged code.

The following is the code −

static unsafe void Main(string[] args) {
   int x = 100;
   int* a = &x;

   Console.WriteLine("Data : {0} ", x);
   Console.WriteLine("Address : {0}", (int)a);
Updated on 22-Jun-2020 13:22:42