You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
It's fine to use them, of course. Just be aware that the lifetime of each using is the entire method. If you stick to shorter methods without or with limited side-effects, then this won't be a problem. Just make sure that you're not allowing the lifetime of an IDisposable be extended unnecessarily because you didn't close it off with braces. If this is happening, then you probably have a method that's doing two things anyway and you can take this as a hint that you should split the method, possibly using local functions to determine the disposable's lifetime.
The text was updated successfully, but these errors were encountered:
Notes
It's fine to use them, of course. Just be aware that the lifetime of each using is the entire method. If you stick to shorter methods without or with limited side-effects, then this won't be a problem. Just make sure that you're not allowing the lifetime of an
IDisposable
be extended unnecessarily because you didn't close it off with braces. If this is happening, then you probably have a method that's doing two things anyway and you can take this as a hint that you should split the method, possibly using local functions to determine the disposable's lifetime.The text was updated successfully, but these errors were encountered: