I have been working on some code for a while. And I had a question:
What it the difference between these two codes ?
using (FORM formExemple = new FORM ())
{
formExemple.ShowDialog();
}
and
FORM formExemple = new FORM ();
formExemple.ShowDialog();
usingcalls the object’sDispose()method to clean up after itself when it’s done. It usually handles things like closing open connections and/or freeing up memory. If you instantiate it otherwise, you have to do that manually. You can only useusingon objects that implement theIDisposableinterface, which ensures that a methodDispose()exists for the object.