Quick question.
Consider this code
public class Tile
{
public Collision Collision;
public Tile()
{
Collision = new Collision(this);
}
public ~Tile()
{
CollisionHandler.Remove(Collision);
}
}
public class Collision
{
public Collision()
{
CollisionHandler.Add(this);
}
}
public class Main
{
public Main()
{
Test1();
Test2();
}
public void Test1()
{
Tile[,] tiles = new Tile[20,20];
tiles[0,0] = new Tile();
tiles[0,0] = new Tile();
//Would calling the above call the old Tile's destructor?
}
public void Test2()
{
Tile[,] tiles = new Tile[20,20];
tiles[0,0] = new Tile();
Tile t = new Tile();
tiles[0,0] = t
//Would calling the above call the old Tile's destructor?
}
}
Now, when I run Test1
would the old Tile
's finalizer
be called? What about Test2
?