Object Cloning
Structures and classes have some fundamental differences. One important difference is that structures support copy-on-assignment, whereas classes do not. Thus classes lack automatic support for making a copy of an object. You must decide whether you want to add explicit object cloning support on a class-by-class basis.
When you want to create a class that supports object cloning, you must provide a custom instance method that is responsible for producing a copy of the current object. By convention, this method should be named Clone and its containing class should explicitly implement the ICloneable interface to advertise the fact that its objects support cloning. Listing 10.6 shows an example of a class named Dog that supports ...
Get Building Applications and Components with Visual Basic .NET now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.