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(); }
static void Main(string[] args) { Developer dev = new Developer(); dev.Name = "Bob"; dev.Role = "Team Leader"; dev.PreferredLanguage = "C#"; Developer devCopy = (Developer)dev.Clone(); devCopy.Name = "Sue"; Console.WriteLine(dev); Console.WriteLine(devCopy); Typist typist = new Typist(); typist.Name = "John"; typist.Role = "Doe"; typist.WordsPerMinute = 120; Typist typistCopy = (Typist)typist.Clone(); typistCopy.Name = "Tim"; typistCopy.WordsPerMinute = 115; Console.WriteLine(typist); Console.WriteLine(typistCopy); Console.ReadLine(); }
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()); }
static void Main(string[] args) { var dev = new Developer() { Name = "Bob", Role = "Team Leader", PrefferedLanguage = "C#" }; var devCopy = (Developer)dev.Clone(); devCopy.Name = "Sue"; devCopy.PrefferedLanguage = "Java"; Console.WriteLine(dev); Console.WriteLine(devCopy); var typist = new Typist() { Name = "Sue", Role = "Typist", WordsPerMinute = 120 }; var typistCopy = (Typist)typist.Clone(); typistCopy.Name = "Tim"; typistCopy.WordsPerMinute = 115; Console.WriteLine(typist); Console.WriteLine(typistCopy); Console.ReadKey(); }
static void Main(string[] args) { Developer dev = new Developer(); dev.Name = "Bob"; dev.Role = "Team Leader"; dev.PreferredLanguage = "C#"; Developer devCopy = (Developer)dev.Clone(); devCopy.Name = "Sue"; Console.WriteLine(dev); Console.WriteLine(devCopy); /* OUTPUT * * Bob - Team Leader - C# * Sue - Team Leader - C# * */ Typist typist = new Typist(); typist.Name = "Kay"; typist.Role = "Typist"; typist.WordsPerMinute = 120; Typist typistCopy = (Typist)typist.Clone(); typistCopy.Name = "Tim"; typistCopy.WordsPerMinute = 115; Console.WriteLine(typist); Console.WriteLine(typistCopy); /* OUTPUT * * Kay - Typist - 120wpm * Tim - Typist - 115wpm * */ Console.Read(); }