Ejemplo n.º 1
0
 public static void Run()
 {
     Tree tree1 = new Tree();
     tree1.name = "Ulme";
     Tree tree2 = tree1.Clone() as Tree;
     tree2.name = "Birke";
     Assert.assertThat("name of tree1 is still the same", "Ulme" == tree1.name);
     Tree tree3 = tree1.ImproperClone() as Tree;
     tree3.name = "Birke";
     Assert.assertThat("this works also", "Ulme" == tree1.name);
 }
Ejemplo n.º 2
0
 public object ImproperClone()
 {
     Tree clone = new Tree();
     clone.name = this.name;
     return clone;
 }
Ejemplo n.º 3
0
 public object Clone()
 {
     Tree clone = new Tree();
     clone.name = this.name.Clone() as string;
     return clone;
 }