为什么没有ICloneable&LT; T&GT;? [英] Why no ICloneable<T>?
本文介绍了为什么没有ICloneable&LT; T&GT;?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
有没有特别的原因,为什么一个普通的 ICloneable&LT; T&GT;
不存在
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.
推荐答案
ICloneable被认为是一种不好的API,现在,因为它没有具体的结果是否是深还是浅拷贝。我想这就是为什么他们不提高这个接口。
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.
这篇关于为什么没有ICloneable&LT; T&GT;?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文