Reputation: 2024
OK, I always get confused about this.
Let's say I have this code.
Public Sub Bar(byRef pMap as clsMap)
Dim foo as new FooClass()
pMap.listOfFoo.Add(foo)
end Sub
This would mean that referencing 'Foo' or the item stored in 'listOfFoo' would reference the same object, right? If I was to change a property of 'foo' - but not change it to a new object - both would still reference and would reflect the updated values?
Upvotes: 0
Views: 1396
Reputation: 10064
Yes, you're storing a reference pointer to the foo
object, so if you modify a property in one place, it will be visible in all other places where foo
is referenced.
If you want to make a copy of your object, you should consider object cloning.
Upvotes: 2