object - Simple Question - Shallow Copy (VB.Net) -


OK, I'm always confused about it.

Let's say I have this code.

  Public sub bar (CLSmap as byRef PMM) Dim foo () pMap.listOfFoo.Add (foo) end as new FooClass  

This will mean that items stored in 'Foo' or 'ListOfFoo' will reference the same item, right? If I want to change the property of 'Foo' - but it can not be converted to a new object - both will still be referenced and will reflect the updated values?

Yes, you are accumulating a reference pointers in the object foo , So if you modify a property in one place, then it will appear in all other places where foo is referenced.

If you want to make a copy of your object, you should consider it.


Comments

Popular posts from this blog

c# - sqlDecimal to decimal clr stored procedure Unable to cast object of type 'System.Data.SqlTypes.SqlDecimal' to type 'System.IConvertible' -

Calling GetGUIThreadInfo from Outlook VBA -

Obfuscating Python code? -