In a framework that I have written for my dev team, I have a class that has a method like so: public class ObjectBase { public void Clone( ref ObjectBase target, ObjectBase parent); } This method (virtual in my library, in fact) has two functions: When the target ref is null, then a new object should be created, but when it's not, then the contents of the object on which it's being called should be cloned into the passed object. The parent of the new object is required because in the framework our objects have keys that can come from multiple sources - including an expression on the parent. Anyway, whilst this method is particularly useful, it's a little unfriendly to use from your code when you don't have a direct ObjectBase reference to pass, but instead a reference to an object derived from it: public class MyObject : ObjectBase { } public static void main() { MyObject obj = new MyObject (); MyObject ...
Replacing my old blog at http://www.lordzoltan.org. C#, rants and other brain vomit