Is this code clean?
private void button1_Click(object sender, EventArgs e) { frmCustomDialog f = new frmCustomDialog(); if(f.ShowDialog() == DialogResult.OK) TextBox1.Text = f.MyCustomProperty; }
Do you need to close or dispose the form f or anything? Or is it automatically garbage-collected?
Thank you.
If you are showing form as dialog form (which you are since you’re calling it with the form.ShowDialog()), then you have to manually dispose of the object, because Close method of the form is not automatically called when closing the form (the form is hidden instead).
You can read more here.