title: Deep Copy with Array
body: <p>Why doesn't <code>ICloneable</code>'s <code>Clone</code> method return a deep copy?</p>
  <p>Here is some sample code:</p>
  <pre><code>class A : ICloneable 
  {
      public int x = 2;
      public A(int x)
      {
         this.x = x; 
      }
         
      public A copy()
      {
          A a = new A(this.x);
          return a; 
      }
  
       public object Clone()
       {
           A a = new A(this.x);
           return a;
       }
  }
  </code></pre>
  <p>In the <code>Main</code> method :</p>
  <pre><code>A[] Array1 = new A[4] ;
  Array1[0] = new A(0);
  Array1[1] = new A(1);
  Array1[2] = new A(2);
  Array1[3] = new A(3);
  A[] Array2 = new A[10];
  Array. Copy(Array1, Array2, 4); 
  
  Array2[2].x = 11; 
  for (int i = 0; i &lt; 4; i++)
      Console.WriteLine($&quot;Index {i} value: {Array1[i].x}&quot;);
  </code></pre>
  <p>Remembering that I've only changed element index 2 in <code>Array2</code>, here is the output from the code above, listing the values in <code>Array1</code>:</p>
  <pre><code>Index 0 value: 0
  Index 1 value: 1
  Index 2 value: 11
  Index 3 value: 3
  </code></pre>
  <p>Index 2 in <code>Array1</code> has <code>11</code> even though I changed it in <code>Array2</code> and class <code>A</code> implements <code>ICloneable</code>!</p>
  <p>What then is the benefit of <code>Array</code> implementing <code>ICloneable</code>?</p>