I am learning managed and unmanaged code in the CLR. So I wrote this example with C style pointers in C #:
unsafe static void Main(string[] args) { int x; int* y; y = &x; *y = 50; Console.WriteLine(*y); Console.WriteLine(((int)y).ToString()); }
So, I am wondering what is actually unsafe in the IL code that I received from the code above?
.assembly extern mscorlib {} .assembly UnsafePointers {} .module UnsafePointers.exe .class private auto ansi beforefieldinit UnsafePointers.Program extends [mscorlib]System.Object { .method private hidebysig static void Main(string[] args) cil managed { .entrypoint
Does the CLR support this code? And what could go wrong with the code above?
pointers c # clr unsafe il
vldmrrdjcc
source share