Wednesday, December 21, 2005

ByVal or ByRef

When to you ByVal and when to use ByRef?
This is a very basic (fundamental) question that asked by newbies, and a simple answer would be ByVal simply duplicate the variable (create a new identical one) and give to the function you passed to, that means it is two different variable which whatever changes made in that function will not reflect in your original variable. And ByRef simple do the other way by passing a Reference of the original variable so effectively it is the same variable which changes made will be shown in the original variable.

But there cames the idea of Value Type and Reference Type, this article demonstrate the idea.

Now, while I'm looking into my weird problem with my DAL, which I made lots of ByRef for ReferenceType, I actually wanted to know whether there's any implication here, where it could be that everytime a call to a ByRef, it allocates a pointer on a pointer array (or some kind of table) and it happens that the pointer array strinks during garbage collection and some weird things happened?

If you have any idea, drop me a note please!

No comments: