Example #1
0
        public Dude CopyDude()
        {
            Dude newPerson = new Dude();

            newPerson.Name      = Name;
            newPerson.LeftShoe  = LeftShoe;
            newPerson.RightShoe = RightShoe;

            return(newPerson);
        }
Example #2
0
        static void Main(string[] args)
        {
            var dude    = new Dude();
            var redShoe = new Shoe()
            {
                Color = "red"
            };
            var blueShoe = new Shoe()
            {
                Color = "blue"
            };

            dude.LeftShoe  = redShoe;
            dude.RightShoe = blueShoe;

            var dude2 = dude.CopyDude();

            dude2.LeftShoe.Color = "zelen";

            // Change Shoe from struct to class and observe thе differences

            Console.WriteLine(dude);
            Console.WriteLine(dude2);
        }