Below is my class
public Class Test
{
int id {get;set;}
string name {get;set;}
}
I am creating an object of this class and assigning values.
var obj = new Test();
obj.id = 1;
obj.name = "test";
var newobj = obj;
newobj.name ="NewTest";
Below is the output
Console.WriteLine(obj.name); //NewTest
Console.WriteLine(newobj.name); //NewTest
Why value of obj is changing when i change value of a property present in new obj. I know its very solution, I am not sure why I am not able to find. I don't want value of obj to get changed if i changed value in newobj.