开发者

Using the using statement with WinForms... Good Practice?

开发者 https://www.devze.com 2022-12-22 02:51 出处:网络
I understand the concept and reasons behind using the using statement, and I use it with things like file resources and remote conne开发者_如何转开发ctions, I was wondering if it is good practice to

I understand the concept and reasons behind using the using statement, and I use it with things like file resources and remote conne开发者_如何转开发ctions, I was wondering if it is good practice to use the using statement with WinForm forms and dialogs?

using (MyDialog dlg = new MyDialog())
{
    if (dlg.ShowDialog() == EDialogResult.OK)
    {
        // Do Something
    }
}

Thanks!


With Dialogs only. But then it is a very good practice.

You will find that it doesn't work around Show(), because using(){} can only be used inside 1 method and you never want to Close again right after a Show().

0

精彩评论

暂无评论...
验证码 换一张
取 消