ICloneable.Clone 方法


创建作为当前实例副本的新对象。Creates a new object that is a copy of the current instance.

 System::Object ^ Clone();
public object Clone ();
abstract member Clone : unit -> obj
Public Function Clone () As Object



作为此实例副本的新对象。A new object that is a copy of this instance.


生成的克隆必须与原始实例具有相同的类型,或与其兼容。The resulting clone must be of the same type as, or compatible with, the original instance.

的实现 Clone 可以执行深层复制或浅表复制。An implementation of Clone can perform either a deep copy or a shallow copy. 在深层复制中,所有对象都是重复的;在浅表复制中,只复制顶级对象,而较低级别包含引用。In a deep copy, all objects are duplicated; in a shallow copy, only the top-level objects are duplicated and the lower levels contain references. 因为的调用方 Clone 不能依赖于执行可预测的克隆操作的方法,所以我们建议 ICloneable 不要在公共 api 中实现。Because callers of Clone cannot depend on the method performing a predictable cloning operation, we recommend that ICloneable not be implemented in public APIs.

Object.MemberwiseClone有关克隆的详细信息,请参阅深度与浅表副本和示例。See Object.MemberwiseClone for more information on cloning, deep versus shallow copies, and examples.