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) { // Typist object Typist typist1 = new Typist(); typist1.Name = "hello"; System.Console.WriteLine(typist1.Name + Environment.NewLine); Typist typist = typist1.clone() as Typist; System.Console.WriteLine(typist.Name); typist1.Name = "alok"; System.Console.WriteLine($"New name of typist1 is : {typist1.Name}\n"); System.Console.WriteLine($"New name of typist is : {typist.Name}\n"); // Developer object Developer developer1 = new Developer(); developer1.Name = "hello"; System.Console.WriteLine(developer1.Name + Environment.NewLine); Developer developer = developer1.clone() as Developer; System.Console.WriteLine(typist.Name); Console.WriteLine("Hello World!"); }
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) { 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(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(); }