Need I remove controls after disposing them?

后端 未结 6 2093
闹比i
闹比i 2020-12-15 20:52

.NET 2

// dynamic textbox adding
myTextBox = new TextBox();
this.Controls.Add(myTextBox);

// ... some code, finally

// dynamic textbox rem         


        
6条回答
  •  时光取名叫无心
    2020-12-15 21:41

    Just keep in mind that if you have some code to iterate over your controls and do something, you would get an exception if one of these controls had been disposed. Therefore, in general I would probably recommend removing the control as good practice.

提交回复
热议问题