扩展C#中其他命名空间的命名空间 [英] Namespaces that extends other namespace in c#

查看:204
本文介绍了扩展C#中其他命名空间的命名空间的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

namespace X
{
 internal class base
 {

 }
}

namespace X.a
{
  internal class derive:base
  {

  }
}


为什么这样做有效?

尽管X.a是扩展名,但当派生类具有2个不同的命名空间时,如何从基类派生呢?

X.a的命名空间中不应该使用X还是隐式调用它?


在此先感谢.


why does this work?

How can the derive class be derived from the base class when they have 2 diferent namespaces though X.a is an extension?

shouldnt there be a using X in the namespace of X.a or is it implicitly called?


Thanks in advance.

推荐答案

嵌套的名称空间应该对包含的名称空间中的类型具有依赖性.例如,System.Web.UI.Design中的类取决于System.Web.UI中的类.但是,System.Web.UI中的类不依赖于System.Web.UI.Design中的类.

检查此

http://msdn.microsoft.com/en-us/library/893ke618 (v = vs.71).aspx [
A nested namespace should have a dependency on types in the containing namespace. For example, the classes in the System.Web.UI.Design depend on the classes in System.Web.UI. However, the classes in System.Web.UI do not depend on the classes in System.Web.UI.Design.

Check this

http://msdn.microsoft.com/en-us/library/893ke618(v=vs.71).aspx[^]


这篇关于扩展C#中其他命名空间的命名空间的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆