I've read (on using
Statement (C# Reference)) that the using
statement should be used to release the resources used by managed types (like File and Font) that use unmanaged resources. So started using it with MySql classes and related stuff, but if you take a look at an object of a Windows.Forms.Form class you will see a Dispose method, it means that this class implements IDisposable so, should I use a using
statement for a Windows.Forms.Form object like in the case below?
private void aboutToolStripMenuItem_Click(object sender, EventArgs e)
{
using (AboutBoxProjeto about = new AboutBoxProjeto())
{
about.ShowDialog();
}
}
From http://dotnetfacts.blogspot.com/2008/03/things-you-must-dispose.html:
In .NET, a dialog form is a form opened by calling the ShowDialog() method. Unlike modeless forms, the Close method is not called by the .NET Framework when the user clicks the close form button of a dialog box or sets the value of the DialogResult property. Instead the form is hidden and can be shown again without creating a new instance of the dialog box. Because a form displayed as a dialog box is not closed, you must call the Dispose() method of the form when the form is no longer needed by your application
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With