//save the current origin value
Employee temp = Origin;
// do some staff with origin and it changes the origin value.
//restore origin to the temp
Origin = temp;
//here i expected the origin value restore to the temp but it doesn't.
temp value changes with origin value. in other word both temp and origin has the same values!!!
I want to save Origin value and the restore it, but if origin changes the temp changes too. Its like compiler doesn't initiate temp.
I guess its a real fundamental developing knowledge but i couldn't find the answer. so sorry about that.
UPDATE so far i tried these but non of them worked:
var temp = Origin;
object tmp = temp;
Origin = (Employee)tmp;
var temp = new Employee();
temp = Origin;
Origin = temp;
finally as dear @erikscandola said I copy all properties one by one in to the temp object and its worked. but that was very hard(assuming the Employee is real big object). is there a better way to do such a thing? it really seems easy.
