user210757
user210757

Reputation: 7386

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 convention 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?

Upvotes: 2

Views: 177

Answers (1)

Gary Linscott
Gary Linscott

Reputation: 1471

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 */ }

Upvotes: 1

Related Questions