-3

In the code example below, does the RadioButton rb still exist in Form mainForm after the code leaves the using statement and rb is disposed?

using (var rb = new RadioButton())
{
    rb.Text = "Test Radio Button";
    rb.Checked = true;

    mainForm.MyPanel.Controls.Add(rb);   
}
user1172282
  • 527
  • 1
  • 9
  • 19

1 Answers1

1

It still exists as an object, but it may be trash, as you have Disposed it, once execution leaves that using block.

Rowland Shaw
  • 37,700
  • 14
  • 97
  • 166