Item 32: Avoid ICloneable(Effective C#)
2011-02-21 21:06
525 查看
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.
相关文章推荐
- Effective C#之Item 27: Avoid ICloneable
- Effective C# Item 27: Avoid ICloneable
- Item 34: Avoid Overloading Methods Defined in Base Classes(Effective C#)
- Item 9: Avoid Conversion Operators in Your APIs(Effective C#)
- Effective C#之Item 32:Prefer Smaller, Cohesive Assemblies
- Item 26: Avoid Returning References to Internal Class Objects(Effective C#)
- Effective C#之Item 28: Avoid Conversion Operators
- Item 16: Avoid Creating Unnecessary Objects(Effective C#)
- Effective C# 原则27:避免使用ICloneable(译)
- [翻译] Effective C++, 3rd Edition, Item 32: 确保 public inheritance 模拟 "is-a"(下)
- 《Effective C#》Item 7:推荐使用不可改变的原子值类型
- 《Effective C#》Item 14:使用构造函数初始化语句
- Effective C++学习笔记(Part Six:Item 32-40)
- 《Effective C#》Item 20:区分接口实现与虚函数重载
- Effective C#:Item1:使用属性而不是可访问数据成员
- 《Effective C#》Item 3:使用as和is操作符来做类型转换
- 《Effective C#》Item 16:尽量减少垃圾产生的数量
- 转:《Effective C#》Item 8:确保“0”在值类型中是有效的
- EF映射——linq to Entity ,不支持方法 get_item(int 32) 无法转换为存储表达式
- Effective C# 避免ICloneable接口