Does calling Clear disposes the items also?

前端 未结 4 1596
予麋鹿
予麋鹿 2021-01-07 19:54

Many times there is a clear method, that removes all the items from the collections, are these items disposed also.

Like,

toolStripMenuItem.DropDown         


        
4条回答
  •  被撕碎了的回忆
    2021-01-07 20:40

    Calling Clear doesn't dispose the items, but it removes the reference from the collection to the items. If that was the only reference to the items they will be garbage collected automatically at some point (which you can't predict, but you may control using the GC class).

提交回复
热议问题