Does the "using" directive provide any benefit?

Posted by Adam Drummond on Stack Overflow See other posts from Stack Overflow or by Adam Drummond
Published on 2012-04-11T17:21:29Z Indexed on 2012/04/11 17:29 UTC
Read the original article Hit count: 207

Filed under:
|

Is there a programmatic benefit to using a using statement?

Notice the difference between this sample:

using Application.Data;
namespace Application.Web
{
    public class SampleClass
    {
        public void SampleMethod()
        {            
            List<Category> categories = CreateCategoriesData();
            Category expected = categories[0];
            ...
        ...
        }
    }
}

And this one:

namespace Application.Web
{
    public class SampleClass
    {
        public void SampleMethod()
        {            
            List<Data.Category> categories = CreateCategoriesData();
            Data.Category expected = categories[0];
            ...
        ...
        }
    }
}

© Stack Overflow or respective owner

Related posts about c#

Related posts about .NET