Object references
I just had a nice discussion at work, it reminded me of some things I thought I had complete knowledge about!
In Visual Basic .NET you can pass variables into a method in two ways; either by ByRef or by ByVal.
If you use ByRef then you pass the pointer to the object, and any modifications to the pointer will remain the same after the method has executed.
If you use ByVal then you create a local copy of the pointer that was passed, and any modifications to the pointer will be lost. Although, any modifications done to the object that the local copy points at will remain the same after the method has finished its execution – because the original pointer points at the object that was modified!
For built-in types, this is NOT the same.
If you use ByRef on an Integer for example, the modification will remain true after the method execution.
But if ByVal is used instead, the modification will be void after the method execution.
My name is Bengt Ericsson. I'm 22 years old, and I'm a software developer. And I love code! Nothing makes me more happy than a stunningly beautiful and well thought out LOC!















Recent Comments