Ray's playground

 

Item 32: Avoid ICloneable(Effective C#)

ICloneable does have its use, but it is the exception rather than rule. It’s significant that the .NET Framework did not add an ICloneable<T> when it was updated with generic support. You should never add support for ICloneable to value types; use the assignment operation instead. You should add support for ICloneable to leaf classes when a copy operation is truly necessary for the type. Base classes that are likely to be used where ICloneable will be supported should create a protected copy constructor. In all other cases, avoid ICloneable.

posted on 2011-02-21 21:06  Ray Z  阅读(168)  评论(0编辑  收藏  举报

导航