Example #1
0
        static void Main(string[] args)
        {
            Detalles detalles = new Detalles()
            {
                Color = "Blanco", Raza = "Dogo"
            };
            Animal animal = new Animal()
            {
                Nombre = "Perro", Patas = 2, Detalles = detalles
            };

            Animal animalClon = animal.Clone() as Animal;

            animalClon.Detalles.Raza = "Doberman";

            Console.WriteLine("-----------------------------");
            Console.WriteLine("CON PROTOTYPE DEEP");
            Console.WriteLine("-----------------------------\n");

            Console.WriteLine("Original: " + animal.Detalles.Raza);
            Console.WriteLine("Clonado: " + animalClon.Detalles.Raza);


            if (Console.ReadKey().Key != ConsoleKey.Escape)
            {
            }
        }
Example #2
0
        public object Clone()
        {
            Animal   clonado      = this.MemberwiseClone() as Animal;
            Detalles detallesClon = new Detalles();

            detallesClon.Color = this.Detalles.Color;
            detallesClon.Raza  = this.Detalles.Raza;
            clonado.Detalles   = detallesClon;
            return(clonado);
        }