﻿<?xml version="1.0" encoding="utf-8"?><Type Name="ICloneable" FullName="System.ICloneable" FullNameSP="System_ICloneable" Maintainer="ecma"><TypeSignature Language="ILASM" Value=".class interface public abstract ICloneable" /><TypeSignature Language="C#" Value="public interface ICloneable" /><TypeSignature Language="ILAsm" Value=".class public interface auto ansi abstract ICloneable" /><MemberOfLibrary>BCL</MemberOfLibrary><AssemblyInfo><AssemblyName>mscorlib</AssemblyName><AssemblyPublicKey>[00 00 00 00 00 00 00 00 04 00 00 00 00 00 00 00 ]</AssemblyPublicKey><AssemblyVersion>1.0.5000.0</AssemblyVersion><AssemblyVersion>2.0.0.0</AssemblyVersion><AssemblyVersion>4.0.0.0</AssemblyVersion></AssemblyInfo><Interfaces /><Attributes><Attribute><AttributeName>System.Runtime.InteropServices.ComVisible(true)</AttributeName></Attribute></Attributes><Docs><remarks><attribution license="cc4" from="Microsoft" modified="false" /><para>The <see cref="T:System.ICloneable" /> interface enables you to provide a customized implementation that creates a copy of an existing object. The <see cref="T:System.ICloneable" /> interface contains one member, the <see cref="M:System.ICloneable.Clone" /> method, which is intended to provide cloning support beyond that supplied by <see cref="M:System.Object.MemberwiseClone" />.  For more information about cloning, deep versus shallow copies, and examples, see the <see cref="M:System.Object.MemberwiseClone" /> method.</para></remarks><summary><attribution license="cc4" from="Microsoft" modified="false" /><para>Supports cloning, which creates a new instance of a class with the same value as an existing instance.</para></summary></Docs><Members><Member MemberName="Clone"><MemberSignature Language="ILASM" Value=".method public hidebysig virtual abstract object Clone()" /><MemberSignature Language="C#" Value="public object Clone ();" /><MemberSignature Language="ILAsm" Value=".method public hidebysig newslot virtual instance object Clone() cil managed" /><MemberType>Method</MemberType><AssemblyInfo><AssemblyVersion>1.0.5000.0</AssemblyVersion><AssemblyVersion>2.0.0.0</AssemblyVersion><AssemblyVersion>4.0.0.0</AssemblyVersion></AssemblyInfo><ReturnValue><ReturnType>System.Object</ReturnType></ReturnValue><Parameters /><Docs><example><para>The following example shows an implementation of <see cref="M:System.ICloneable.Clone" /> that
   uses the <see cref="M:System.Object.MemberwiseClone" />
   method to create a copy of
   the current instance.</para><code lang="C#">using System;
class MyClass :ICloneable {
    public int myField;
    public MyClass() {
        myField = 0;
    }
    public MyClass(int value) {
        myField = value;
    }
    public object Clone() {
        return this.MemberwiseClone();
    }
}
public class TestMyClass {
    public static void Main() {
        MyClass my1 = new MyClass(44);
        MyClass my2 = (MyClass) my1.Clone();
        Console.WriteLine("my1 {0} my2 {1}",my1.myField, my2.myField);
        my2.myField = 22;
        Console.WriteLine("my1 {0} my2 {1}",my1.myField, my2.myField);
    }
}
</code><para>The output is</para><c><para>my1 44 my2 44</para><para>my1 44 my2 22</para></c></example><remarks><attribution license="cc4" from="Microsoft" modified="false" /><para>The resulting clone must be of the same type as, or compatible with, the original instance.</para><para>An implementation of <see cref="M:System.ICloneable.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. Because callers of <see cref="M:System.ICloneable.Clone" /> cannot depend on the method performing a predictable cloning operation, we recommend that <see cref="T:System.ICloneable" /> not be implemented in public APIs.  </para><para>See <see cref="M:System.Object.MemberwiseClone" /> for more information on cloning, deep versus shallow copies, and examples.</para></remarks><summary><attribution license="cc4" from="Microsoft" modified="false" /><para>Creates a new object that is a copy of the current instance.</para></summary><returns><attribution license="cc4" from="Microsoft" modified="false" /><para>A new object that is a copy of this instance.</para></returns></Docs><Excluded>0</Excluded></Member></Members><TypeExcluded>0</TypeExcluded></Type>