At attempt to copy object b the object a is copied
using System; public interface IClonable{ object Clone(); } public class Array:IClonable{ int size; int[] ptr = {}; public object Clone() { return new Array { size = this.size, ptr = this.ptr }; } public Array(){ size = 3; ptr = new int[size]; for(int ix=0; ix<size; ix++){ ptr[ix]=ix; Console.WriteLine(ptr[ix]); } } public Array(int size){ this.size = size; ptr = new int[size]; for(int ix=0; ix<size; ix++){ ptr[ix]=ix; Console.WriteLine(ptr[ix]); } } } public class Test { public static void Main() { Array a = new Array(); Array b = new Array(5); Array c = (Array)b.Clone(); } }
abeing copied? - Grundyptr = this.ptris not cloning. - Qwertiy ♦