Esempio n. 1
0
        static void Main(string[] args)
        {
            Developer dev = new Developer();

            dev.Name = "Rahul";
            dev.Role = "Team Leader";
            dev.PreferredLanguage = "C#";

            Developer devCopy = (Developer)dev.Clone();

            devCopy.Name = "Arif"; //Not mention Role and PreferredLanguage, it will copy above

            Console.WriteLine(dev.GetDetails());
            Console.WriteLine(devCopy.GetDetails());

            Typist typist = new Typist();

            typist.Name           = "Monu";
            typist.Role           = "Typist";
            typist.WordsPerMinute = 120;

            Typist typistCopy = (Typist)typist.Clone();

            typistCopy.Name           = "Sahil";
            typistCopy.WordsPerMinute = 115;//Not mention Role, it will copy above

            Console.WriteLine(typist.GetDetails());
            Console.WriteLine(typistCopy.GetDetails());

            Console.ReadKey();
        }
Esempio n. 2
0
        static void Main()
        {
            Developer dev = new Developer();

            dev.Name = "Johnny";
            dev.Role = "Team Leader";
            dev.PreferredLanguage = "C#";

            Developer devCopy = (Developer)dev.Clone();

            devCopy.Name = "Asparuh";
            devCopy.Role = "Software Architect";

            Console.WriteLine(dev.GetDetails());
            Console.WriteLine(devCopy.GetDetails());

            Typist typist = new Typist();

            typist.Name           = "Monty";
            typist.Role           = "Typist";
            typist.WordsPerMinute = 120;

            Typist typistCopy = (Typist)typist.Clone();

            typistCopy.Name           = "Sancho";
            typistCopy.Role           = "Junior Typist";
            typistCopy.WordsPerMinute = 95;

            Console.WriteLine(typist.GetDetails());
            Console.WriteLine(typistCopy.GetDetails());
        }