Item 32: Avoid ICloneable(Effective C#)

你的名字 2021-11-10 00:24 248阅读 0赞

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 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.

转载于:https://www.cnblogs.com/zhtf2014/archive/2011/02/21/1960122.html

发表评论

表情:
评论列表 (有 0 条评论,248人围观)

还没有评论,来说两句吧...

相关阅读