I have 2 data classes:
class A
{
public int n { get; set; }
}
class B
{
public A obj { get; set; }
}
And in the main program, I create an B object and assign value to B.obj like this:
A a = new A() { n = 1 };
B b = new B() { obj = a };
It looks good until here, but when I assign a new value to a like this:
a = new A() { n = 5 };
and then check b.obj again but the value is still 1 but not 5
I know that objects in C# are reference type so I thought b.obj always refers to memory address of object a, but it seems it's not...
Is there any way to make b.obj always refer to memory of object a?