Recently I came up with an idea (that I really don't know whether it would exist or even work) of automatically updating a Class
's properties using a modified instance of it. And, to make my idea a little bit more clear, I will explain it in the code below"
//The first (Main) instance of the Class
Employee carl = new Employee();
carl.Name = "Carl";
carl.Age = 20;
carl.Salary = 7000;
//Here is the same employee data collected from the database a year after:
Employee carl_one_year_later = new Employee();
carl_one_year_later.Age = 21;
carl_one_year_later.Salary = 10000;
//My idea is that I want to dynamically merge the new collected data to the current main instance of the employee, without missing out the unupdated data (i.e.: his name)
employee1 = employee2; //Using this seems to overwrite the Name Field with Null.
Some might say you can simply achieve this by doing this:
carl.Age = carl_one_year_later.Age;
carl.Salary = carl_one_year_later.Salary;
However, I want a dynamic way to just do this in 1 line of code and let C# handle the property set
for me. Also, it may come in handy if we have a massive class that we don't want to set its properties every time they are updated one by one.