ByRef

  • Thread starter Thread starter Guest
  • Start date Start date
Arne Garvander said:
Is a reference type value the same as an object?

I expressed myself badly. When you have a variable whose type is a
reference type, the value of that variable is a reference. It's not the
object itself, it's a reference to the object. Suppose you had:

string x = "some very long string indeed which would be large etc";

then the value of x is just a reference - 4 or 8 bytes depending on
your platform. When you use x as an argument to a method, only 4 (or 8)
bytes are copied - the reference. The object itself is on the heap, and
the new copy of the reference points to the same object as the "old"
reference.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top