C
Cybertof
Hi !
I thought the GC was doing the job of cleaning ressources....
Do you know why Microsoft is using Dispose in this sample ?
[C#]
public void ShowMyDialogBox()
{
Form2 testDialog = new Form2();
if (testDialog.ShowDialog(this) == DialogResult.OK)
{
// Read the contents of testDialog's TextBox.
this.txtResult.Text = testDialog.TextBox1.Text;
}
else
{
this.txtResult.Text = "Cancelled";
}
testDialog.Dispose();
}
Link :
http://msdn.microsoft.com/library/default.asp?url=/library/en-
us/cpref/html/frlrfSystemWindowsFormsFormClassShowDialogTopic.asp
Regards,
Cybertof.
I thought the GC was doing the job of cleaning ressources....
Do you know why Microsoft is using Dispose in this sample ?
[C#]
public void ShowMyDialogBox()
{
Form2 testDialog = new Form2();
if (testDialog.ShowDialog(this) == DialogResult.OK)
{
// Read the contents of testDialog's TextBox.
this.txtResult.Text = testDialog.TextBox1.Text;
}
else
{
this.txtResult.Text = "Cancelled";
}
testDialog.Dispose();
}
Link :
http://msdn.microsoft.com/library/default.asp?url=/library/en-
us/cpref/html/frlrfSystemWindowsFormsFormClassShowDialogTopic.asp
Regards,
Cybertof.