I migrate between C++ and VB.NET in my coding ventures... which leads to the occasional confusion about when something is by value or by reference in VB.NET.
Let's say for example that I have an array of MyObject which is populated with a bunch of objects.
dim MyArr(5000) of MyObject
Now let's say that the information from this array travels throughout various data structures:
dim MyList as new List(of MyObject)
for i as integer = 0 to 5000 step 1000
Mylist.add(MyArr(i))
next
then
dim MyTable as new HashTable
dim i as integer = 0
for each O as MyObject in Mylist
if i mod 2 = 0 then
MyTable.add(O.ToString(), O)
end if
next
Under the above scenario, I believe everything is by reference. If I extract an entry from "MyTable" and modify its MyObject Members, I think that the original in MyArr will be modified.
However, I have run into situations where I thought something was by reference, and it was by value.
Are items always added to containers by reference, or are they sometimes added by value?
I'm confused.