Skip to content

Instantly share code, notes, and snippets.

@controlflow
Last active August 22, 2019 10:36
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save controlflow/f0629523304b5f425062b30d6468dca1 to your computer and use it in GitHub Desktop.
Save controlflow/f0629523304b5f425062b30d6468dca1 to your computer and use it in GitHub Desktop.
// 1
foreach (var x in xs)
using (var r = x.GetResource())
DoWork(x, r);
// 2
foreach (var x in xs)
using (var r = x.GetResource()) {
DoWork(x, r);
DoOtherWork(r);
}
// 1
foreach (var x in xs) {
using var r = x.GetResource();
DoWork(x, r);
}
// 2
foreach (var x in xs) {
using var r = x.GetResource();
DoWork(x, r);
DoOtherWork(r);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment