Lifetime of objects in a collection in VB.Net

前端 未结 4 481
醉话见心
醉话见心 2021-01-15 16:42

I\'m trying to figure out the lifetime of the tmpTabPages in the following bit of code. Lets assume the form has an empty TabControl named MyTabControl, that there\'s a coll

4条回答
  •  离开以前
    2021-01-15 17:25

    because soemthing has a reference to the controls they will not be disposed of.

    yes the lifetime would be till the end of the procedure if you were not adding a reference to them to the colelction.

    the clear will remove the objects from the collection and they will get garbage collected provided there are no other references to them (which there shuoldnt be in the situation you describe)

提交回复
热议问题