为什么 using 指令位于 Silverlight 4/VS 2010 中的命名空间内?

发布于 2024-09-01 21:39:54 字数 431 浏览 1 评论 0原文

为什么 Silverlight 4/VS 2010 中的命名空间内的 using 语句是自动生成的代码?

新的约定似乎不是

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

    public myClass() {}
}

标准:

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

namespace myNamespace
{

    . . .

    public myClass() {}
}

这有什么原因或优势吗?或者这就是他们的做法?

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?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

胡渣熟男 2024-09-08 21:39:54

主要是风格偏好。有一个非常小的优点,如果您在同一个文件中使用多个根命名空间,则使用范围仅限于命名空间。

IE。

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

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 */ }
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文