Not completing a using block

G

Guest

Is there any difference in resource usage (or rather disposal between)

using (something resource intensive)
{
DoSomething()
}
return

....and....

using (something resource intensive)
{
DoSomething()
return
}
 
J

Jon Skeet [C# MVP]

Is there any difference in resource usage (or rather disposal between)

using (something resource intensive)
{
DoSomething()
}
return

...and....

using (something resource intensive)
{
DoSomething()
return
}

Well, if the return statement needs to evaluate anything, the order of
disposal and evaluation will change. In both cases Dispose is called
though.
 
I

Ignacio Machin \( .NET/ C# MVP \)

Hi,




Paulustrious said:
Is there any difference in resource usage (or rather disposal between)

using (something resource intensive)
{
DoSomething()
}
return

...and....

using (something resource intensive)
{
DoSomething()
return
}


Nop, personally I prefer the first one.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top