How to make a copy of an object
I have a collection of objects called Bookmarks that consists of a collection of Bookmarks. This collection of bookmarks is bound to the TreeView control.
I can get the bookmarks I want, but I need a copy of the bookmarks so I can work with it and not modify the original.
Any thoughts.
Thank.
source to share
Create a new constructor for the bookmark class that takes the existing bookmark as a parameter.
Inside this new constructor, copy all property values from the existing bookmark to the new one.
This method is known as "Copy Constructor".
The article takes a closer look at the MSDN article, see How to Write a Copy Constructor .
source to share
Usually you don't make a copy of an object, the object makes a copy of itself (a clone). Because the object contains state information, a bitwise copy cannot be considered appropriate; so the defining class must take care of this.
In your case, you can implement multiple concurrent pointers (bookmarks).
source to share