Skip to content
Discussion options

You must be logged in to vote

If I'm correct, the using proposal is actually saving a bit more for some situations:

TResult result;
using (var r = new Resource())
    result = DoSomething(r);
DoAnother(result);

becomes:

DoAnother(DoSomething(using new Resource());

But this only benifits if you need to dispose the resource as eager as possible, which is uncommon. Otherwise, you can dispose the resource after everything on the result are done.

Replies: 4 comments

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Answer selected by Acerby
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
5 participants
Converted from issue

This discussion was converted from issue #2628 on October 29, 2020 07:41.