Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add notes on using statements (without braces) #8

Open
mvonballmo opened this issue Jan 24, 2022 · 0 comments
Open

Add notes on using statements (without braces) #8

mvonballmo opened this issue Jan 24, 2022 · 0 comments

Comments

@mvonballmo
Copy link
Owner

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant