Search code examples
c#.neticloneable

Why no ICloneable<T>?


Is there a particular reason why a generic ICloneable<T> does not exist?

It would be much more comfortable, if I would not need to cast it everytime I clone something.


Solution

  • ICloneable is considered a bad API now, since it does not specify whether the result is a deep or a shallow copy. I think this is why they do not improve this interface.

    You can probably do a typed cloning extension method, but I think it would require a different name since extension methods have less priority than original ones.