【问题标题】:Why are the using directives inside of the namespace in Silverlight 4/VS 2010?为什么在 Silverlight 4/VS 2010 的命名空间内使用 using 指令?
【发布时间】:2011-02-20 15:50:49
【问题描述】:

为什么 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() {}
}

这样做有什么理由或优势,还是他们就是这样做的?

【问题讨论】:

    标签: visual-studio silverlight-4.0 namespaces using-statement


    【解决方案1】:

    主要是风格偏好。如果在同一个文件中使用多个根命名空间,那么 usings 的作用域是命名空间。

    即。

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

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2011-02-26
      • 1970-01-01
      • 2020-05-20
      • 1970-01-01
      • 2011-06-28
      • 2022-10-14
      • 2013-02-26
      • 2011-04-29
      相关资源
      最近更新 更多