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.
本文章为转载内容,我们尊重原作者对文章享有的著作权。如有内容错误或侵权问题,欢迎原作者联系我们进行内容更正或删除文章。
上一篇:Item 33: Use the new Modifier Only to React to Base Class Updates(Effective C#)
下一篇:Item 31: Implement Ordering Relations with IComparable<T> and IComparer<T>(Effective C#)

提问和评论都可以,用心的回复会被更多人看到
评论
发布评论
相关文章
-
C# 语法中级
C# 语法中级
c# lambda