【发布时间】:2018-07-18 13:38:36
【问题描述】:
我想知道为什么在使用 Type 类中的方法时,我们需要将 using System.Reflection 与 using System 分开指定。反射是嵌套命名空间,位于 System 命名空间内吗?
【问题讨论】:
标签: c# reflection namespaces system
我想知道为什么在使用 Type 类中的方法时,我们需要将 using System.Reflection 与 using System 分开指定。反射是嵌套命名空间,位于 System 命名空间内吗?
【问题讨论】:
标签: c# reflection namespaces system
是的,System.Reflection 是 System 命名空间内的命名空间。 https://msdn.microsoft.com/en-us/library/mt481557(v=vs.110).aspx
【讨论】:
使用 System 命名空间并不包括所有子命名空间。
这里,System.Reflection 是 System.Reflection 的子命名空间。所以你必须通过 using 指令显式地导入它。
注意:相同的原则适用于 c# 中的所有命名空间,例如 System 和 System.IO 等等。
【讨论】: