Michael,
The .NET method is to implement the IClonable interface, as you can enable
it to behave polymorphically. IClonable is relatively easy to implement with
Object.MemberwiseClone, if your hierarchary supports shallow copies.
There was a long thread in microsoft.public.dotnet.general from about 3 Jan
04 titled "Copy constructors and clones" that discusses why IClonable is
"better" then copy constructors.
It also discusses why one may want to implement IClonable in terms of a
protected copy constructor (to support deep copy of Readonly fields).
You should be able to search
http://groups.google.com for the thread.
In addition to copy constructors & cloning, you could also use serialization
to make a copy of an object. (Implementiong IClonable in terms of
serialization is an option, especially when you already implement
serialization).
Hope this helps
Jay
Michael said:
I am implementing object copying in C#. I can think of two ways: (1)Use
the famous C++ way of copy constructor, (2)Use IClonable interface.