Possible Duplicate:
Should Usings be inside or outside the namespace
.NET namespaces and using statements
What is exact difference in writing USING directives before or after namespace declaration.
Example :
using System;
using System.Linq;
using NUnit.Framework;
namespace HostTest
{
/** code goes here **/
}
and
namespace HostService
{
using System.Runtime.Serialization;
using System;
/** code goes here **/
}
Darin’s answer is correct but not comprehensive – because it also makes a difference to how the using directives themselves perform lookup: whether they attempt to match the names within another namespace.
Eric Lippert has a great blog post going into more details. To my mind, the most important point is at the end:
As a corollary, I’d suggest that as the second point means that using directives inside namespaces are trickier to get right than using directives outside namespaces, I’d go with putting them outside. It also helps that that’s the Visual Studio default 🙂
This is all just a compile-time issue though – it only affects how the compiler looks up names, not what the generated code using those names looks like.
One final point of terminology: your question talks about
usingstatements, but all of these areusingdirectives. Theusingstatement is the one that acquires a resource and disposes of it at the end:I mention this only in the spirit of further education – it was obvious what you meant in this particular case 🙂