References are not pointers in C#

As you know, C# supports the concepts of references and value types. Most of the time, reference types tend to be presented as some sort of synonym for a memory address. I’ve seen it everywhere and I’ve used that analogy too when trying to help others to understand the difference between value types and reference types. Now, this kind of analogy tends to break when you start thinking about the memory model and on how GC works.

Say, if reference type is an address, then why do I need to pin it before saving a reference to that address? If you think about references without the address analogy, things start to make more sense…This is just an example of the kind of questions you might end up being asked when you use this sort of analogy to introduce reference types. Fortunately, we’ve got people like Eric Lippert who really  know their stuff and do have the time (and will!) to explain why that is not a good analogy.


~ by Luis Abreu on March 14, 2009.

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: