Hello,
My understanding about objects is that they are reference types and
not value types but a simple code seems to defy my whole
understanding.
I wrote a simple console app:
class Program
{
static void Main(string[] args)
{
A a1 = new A();
a1.i = 1;
a1.j = 2;
A a2 = a1;
a1 = null;
Console.WriteLine(a2.i);
}
}
class A
{
public int i;
public int j;
}
My understanding is a2 and a1 should both both to the same location in
the heap. Once a1 is made null, a2 should also become null but it does
not happen?
Why? Thats the question.