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);
   Console.ReadKey();
}
raja
Published on 31-Aug-2018 14:03:19
Advertisements