public Dude GetShallowCopy() { Dude newPerson = new Dude(); newPerson.Name = Name; newPerson.LeftShoe = LeftShoe; newPerson.RightShoe = RightShoe; return(newPerson); }
public static void Main(string[] args) { Dude bill = new Dude { Name = "Bill", LeftShoe = new Shoe { Color = "Blue" }, RightShoe = new Shoe() { Color = "Blue" } }; Dude ted = bill.Clone() as Dude; ted.Name = "Ted"; ted.LeftShoe.Color = "Red"; ted.RightShoe.Color = "Red"; Console.WriteLine(bill.ToString()); Console.WriteLine(ted.ToString()); }