.NET using block and return; keyword

Posted by Emre on Stack Overflow See other posts from Stack Overflow or by Emre
Published on 2010-03-29T18:26:42Z Indexed on 2010/03/29 18:33 UTC
Read the original article Hit count: 484

Filed under:
|

When I say this

using (Entities db = new Entities())
{
    return db.TableName.AsQueryable().ToList();
}

Do I by-pass the functionality of using block since I return something, and the method exits before exiting the using block, so I think the using block will not serve to its purpose and dispose the resource.

Is this correct?

© Stack Overflow or respective owner

Related posts about .NET

Related posts about using-statement