Barry Kelly wrote:
I sometimes see code where the 'using' statements
at the top of the file are located
before the namespace declaration, and sometimes they are located inside it.
[...]
What is the diference between the two?
If you have more than one namespace declaration in a file, it limits the
scope of the symbols imported by the using declaration.
I'm not aware of any other differences.
One related difference is that using directives can't 'see' directives
in the same scope, but *can* see directives in an outer scope.
For example,
namespace Outer
{
using Regexen = System.Text.RegularExpressions;
//using Regex = Regexen.Regex; // can't see Regexen, here
namespace Inner
{
using Regex = Regexen.Regex;
}
}
The commented-out alias statement in the Outer namespace wouldn't
compile, because it can't 'see' the alias in its scope. However, the
same directive will compile in the Outer.Inner namepscae, because it
can see the alias.
--
..NET 2.0 for Delphi Programmers
www.midnightbeach.com/.net