commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Apache Wiki <>
Subject [Commons Wiki] Update of "CLI" by skolima
Date Tue, 20 May 2008 08:01:41 GMT
Dear Wiki user,

You have subscribed to a wiki page or wiki category on "Commons Wiki" for change notification.

The following page has been changed by skolima:

The comment on the change is:
there is a default shallow copy in .Net!

  - In C# all classes derive from Object, just like Java. Even primitive types are automatically
boxed and unboxed into Object-derived subclasses, just like Java. For a class to be cloneable
it must implement the interface ICloneable and the method 'public object Clone()', just like
Java. However, unlike Java, Object does not implement a shallow clone method. This means that
the logic you implement in your own clone method cannot call the super (or base as it is in
C#) class's Clone method to get a typed, shallow clone. This would not necessarily be a big
deal as you could just create a new class that you are attempting to clone, but if you do
this you would have to be able to clone its properties (assuming they are publicly accessible
or can be set via a constructor) manually -- a cumbersome task.
+ '''check this.MemberwiseClone()'''
  You see the problem. Option is cloneable, and it relies on the Object's clone method. I
toyed around porting this functionality via two methods. The first method looked like this:

To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message