Esempio 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);
 }
Esempio n. 2
0
 public object ImproperClone()
 {
     Tree clone = new Tree();
     clone.name = this.name;
     return clone;
 }
Esempio n. 3
0
 public object Clone()
 {
     Tree clone = new Tree();
     clone.name = this.name.Clone() as string;
     return clone;
 }