关于"名称空间"

peppi 2002-03-30 04:21:44
列位!有理!
我多处见过名称空间一词,并在一些程序里看病到要导入名称空间,我不太清楚它能起什么作用,它该在什么时候导入呢?能不能解释一下,并总结一下都在什么情况下要导入.谢谢!
...全文
33 8 打赏 收藏 转发到动态 举报
写回复
用AI写文章
8 条回复
切换为时间正序
请发表友善的回复…
发表回复
triout 2002-03-31
  • 打赏
  • 举报
回复
如果你会C语言,那么就很好理解:
名称空间就象C中的头文件H,里面包含了一些类的定义,如果你没有引用NAMESPACE,那么你在使用某些CLASS的时候,系统报告说没有定义,因为CLASS不存在(你没有引用)。
peppi 2002-03-31
  • 打赏
  • 举报
回复
谢谢,能不能再说说各位对它的经验,心得?呵~
windfun 2002-03-31
  • 打赏
  • 举报
回复
名称空间是导入一个范围,这个范围内的类可以被asp.net调用
windfun 2002-03-31
  • 打赏
  • 举报
回复
程序最开头
peppi 2002-03-31
  • 打赏
  • 举报
回复
我现在对名称空间的理解是:它就象C或者JAVA里的导入.但我现在不知道是不是在用名称空间的时候要把那个源文件的路径写上?能不能给个小例子?谢谢好心师兄姐!
karma 2002-03-30
  • 打赏
  • 举报
回复
namespace is a way to organize classes so that people will not get confused with names. For example, conductor can mean 列车长 or 音乐指挥,to tell them apart, you put them in different namespaces,
Traffic.Train.Conductor
Music.Orchestra.Conductor

but a lot of times, you do not want to write the full names, so you instruct the compiler to look for the full names inside some namespace imported with
using Traffic.Train;

now you can write
Conductor.StartTheTrainEngine();

the compiler will expand Conductor to Traffic.Train.Conductor. Of course, when you import the two namespaces
using Traffic.Train;
using Music.Orchestra;
at the same time, when you use Conductor, the compiler does not know which one to expand into. In this case, you need to use fully-qualified names
peppi 2002-03-30
  • 打赏
  • 举报
回复
呵呵,不解!
zjq1980 2002-03-30
  • 打赏
  • 举报
回复
.net namespace <---> Java package

62,039

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术交流专区
javascript云原生 企业社区
社区管理员
  • ASP.NET
  • .Net开发者社区
  • R小R
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

.NET 社区是一个围绕开源 .NET 的开放、热情、创新、包容的技术社区。社区致力于为广大 .NET 爱好者提供一个良好的知识共享、协同互助的 .NET 技术交流环境。我们尊重不同意见,支持健康理性的辩论和互动,反对歧视和攻击。

希望和大家一起共同营造一个活跃、友好的社区氛围。

试试用AI创作助手写篇文章吧