I'm adapting the coding style guide from this source: http://www.csharpfriends.com/articles/getarticle.aspx?articleid=336
Under "5.2 Initialization", it recommends the following:
If you initialize a dialog try to use the using statement:
using (OpenFileDialog openFileDialog = new OpenFileDialog()) { }
What are the reasons for this style choice?
Chances are you only need the dialog short-term for immediate input. So, with a using statement, you can free the resources after you've completed what you need from it (Dispose it).
Using is just syntactical sugar for calling the dispose method after use.
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