Given
public class A
{
public B First { get; set; }
}
public class B
{
public C Second { get; set;}
}
public class C
{
public D Third { get; set; }
}
And somewhere in the class you have this
var testClass = new A();
//All the properties have values in it and the class D has a property value that it is holding in to the memory
//testClass.B = new B();
//etc..
What happens if you did testClass = null
? What does testClass's reference now to the heap? And what about D that is holding to a value that it can't collect?
EDIT: Just to clarify, given D has an event that hasn't been unsubscribed and has 10,000 handlers. What happens to testClass = null
?