Manipulating managed data using unsafe

 While exploring the GC classes got a idea can we access a managed data using unmanaged code. So tried the following and got excited so here is the code

class Program
void Main(string[] args)
int a = 0;
int *p = &a;
Console.WriteLine(“the value of a thru p={0}”,*p)

Guess the output
The o/p is
the value of a thru p=0

It works fine with value type. I’m still struggiling to do the same for reference type. Looking for some hack…


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

%d bloggers like this: