Hi Empire,
Comments in-line.
Empire City said:
Can someone tell me what is the difference in placing the using in the
namespace{} and before the namespace{} ?
namespace MyProj
{
using System;
using System.Web;
}
Here the using statements only apply to the code within the block defined by
MyProj. If you added another namespace to the same file, like this:
namespace MyOtherProj
{
class MyClass { Int32 myInt; }
}
You would get a compiler error "The type or namespace Int32 could not be
found...".
using System;
using System.Web;
namespace MyProj
{
}
On this one, the using statements apply to all code in this file. For
example, if I defined:
namespace MyOtherProj
{
}
in the same file, I wouldn't need to re-define the using statements.
I suppose if someone felt a need to define multiple namespaces in the same
file, the second format would be useful.
Joe