Ok, let me than complete what you did not say.
An object is removed as soon as it has no existing reference anymore itself,
or that its reference is used in another object (not being the object
itself).
It can have a reference in a Module or the Class is Shared (static in C#),
Global or in a method. His own reference will set to nothing: as method
goes out of scope, as its object class goes out of scope "me" ("this" in C#)
or as soon as the program stops; or as a reference is set to another object.
But that is not everything, it will not be removed as long as another
something is pointing to the object, while that object itself is not an
object in the list of that.
An Example.
Drag a datagridview on your form, it will be set in the global part of your
form
Create a datatable with a row and add that to your datatable row collection.
Set that datatable as the dataset of your grid
Now the datatable will not be removed as long as you don't set the
dataSource of the datagridview to nothing or to another datatable.
This is an example as we have often seen here, where people thought it went
wrong (a bug) because they did not understand this.
Cor
>
That's not what I said.
Consider the objects A, B, and C, and -denoting a reference:
A -B -C
If A can be reached from the "running code", B and C cannot be finalized.
However, when removing the reference from A to B
A B -C