int iNum = 16; // declaring a value type int
object oVal1 = iNum; // boxing the value type int
object oVal2; // creating a new object reference on the stack
oVal2 = oVal1; // assigning the object reference to another reference
oVal1 = 32; // changing the value of the boxed reference
System.Console.Writeln(oVal1);
System.Console.Writeln(oVal2); //printing the values
Now my ques is
Why does changing the value of the reference of one object does not change the value of the other object as both are references pointing to the same location?
I know that changing the value of a boxed reference does not change its value in the value type.. but when reference typed values are changed should they be reflected in other references also?
object oVal1 = iNum; // boxing the value type int
object oVal2; // creating a new object reference on the stack
oVal2 = oVal1; // assigning the object reference to another reference
oVal1 = 32; // changing the value of the boxed reference
System.Console.Writeln(oVal1);
System.Console.Writeln(oVal2); //printing the values
Now my ques is
Why does changing the value of the reference of one object does not change the value of the other object as both are references pointing to the same location?
I know that changing the value of a boxed reference does not change its value in the value type.. but when reference typed values are changed should they be reflected in other references also?