开发者

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

开发者 https://www.devze.com 2022-12-31 15:18 出处:网络
Why are the using statements inside of the namespace in Silverlight 4/VS 2010 auto-generated code? The new conventi开发者_开发问答on seems to be

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

精彩评论

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

关注公众号