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

paypal - How to know the URL referrer in PHP? -

oauth - Facebook OAuth2 Logout does not remove fb_ cookie -

wpf - Line breaks and indenting for the XAML of a saved FlowDocument? -