开发者

Why are the using directives inside of the namespace in Silverlight 4/VS 2010?

Why are the using statements inside of the namespace in Silverlight 4/VS 2010 auto-generated code?

The new conventi开发者_开发问答on seems to be

namespace myNamespace
{
    using System.Windows.Controls;
    using System.Windows.Navigation;
    . . .

    public myClass() {}
}

rather than the standard:

using System.Windows.Controls;
using System.Windows.Navigation;

namespace myNamespace
{

    . . .

    public myClass() {}
}

Is there any reason for this or an advantage to this, or is this just how they did it?


Mostly stylistic preference. There is the very slight advantage that if you use multiple root namespaces in the same file, the usings are scoped to the namespace.

ie.

namespace Foo { using Blah; }
namespace Bar { /* No Blah context here */ }
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜