ICloneable.Clone メソッド
定義
現在のインスタンスのコピーである新しいオブジェクトを作成します。Creates a new object that is a copy of the current instance.
public:
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.