[学习笔记]c#Primer中文版-命名空间

在msdn中命名空间定义:   命名空间 (namespace) 将相关的类型进行分组的逻辑命名方案。.NET Framework 使用分层命名方案,将类型分为相关功能的逻辑类别,如 ASP.NET 技术或远程处理功能。设计工具可以使用命名空间,使开发人员在他们的代码中浏览和引用类型更为方便。单个程序集可以包含其分层名称具有不同命名空间根的类型,而且逻辑命名空间根可以跨多个程序集。在 .NET Framework 中,命名空间在逻辑设计时提供命名方便,而程序集在运行时确定类型的命名范围。


命名空间是组件开发和团队开发中必备的要素,能解决"全局名称冲突问题",但是事情并不这么简单,有可能"命名冲突问题",这个需要使用别名(alias)处理(using指令):
None.gif namespace  GameApp
ExpandedBlockStart.gifContractedBlock.gif
dot.gif {
InBlock.gif  
//exposes the tow instances of Point
InBlock.gif
  using DisneyAnimation_2DGraphics;
InBlock.gif  
using DreamWorksAnimation_3DGraphics;
InBlock.gif
InBlock.gif  
// OK:Create unique identifiers for each instance
InBlock.gif
  using Point2D = DisneyAnimation_2DGraphics.Point;
InBlock.gif  
using Point3D = DreamWorksAnimation_3DGraphics.Point;
InBlock.gif
InBlock.gif  
class myClass
ExpandedSubBlockStart.gifContractedSubBlock.gif  
dot.gif{
InBlock.gif     Point2D thisPoint;
InBlock.gif     Point3D thatPoint;
ExpandedSubBlockEnd.gif  }

ExpandedBlockEnd.gif}

当然别名(alias)仅在当前生命空间内有效

转载于:https://www.cnblogs.com/pfengk/archive/2006/01/06/312197.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
There are eight directories, representing the eight chapters of the C# Primer text, in which Visual Studio.NET projects are stored. These have all been compiled under a post-Release Candidate, but before the final product release. So, conceivably, these projects may not compiler when you attempt to build them. If that is so, first check my home page for updates (www.objectwrite.com). If your problem is not covered, please mail me at slippman@microsoft.com. I don’t have a good organization for the ASP.NET projects. You may have to open your own, then copy in the form and code behind files. I’ll try to clean that up when I have time. The project listing under each chapter for this release looks as follows: Chapter 1: ArrayListHashtable Arrays BasicTypes FibonacciTries gcFinalize Strings SystemIO Chapter 2: Class Design Enum MatrixVector ParamPassing Stack WordCount Chapter 3: Object-Oriented Programming LibraryMaterial QueryManager Chapter 4: Interfaces binaryTree bitvector Fibonacci Chapter 5: System Framework Environment ExploreRegEx FileIO pathIO RegularExpression socketsClient socketsServer threads XmlDocument XmlDom XmlMisc XmlParse XmlSchema XPath Xslt Chapter 6: Windows.Forms Buttons DataGrid DialogMenu FileDialog HelloWindows HelloWindowsForms ListBox PictureBox Pictures XMLDataGrid Chapter 7: ASP.NET (incomplete) Figure 7_4 Figure 7_5 Figure 7_6 Chapter 8: The Common Language Runtime Assemblies Attributes collectionBinary ildasm reflection serialize tester timer Pictures Textfiles Xmlfiles
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值