using System;
namespace xxx{}
//-----------------------namespace xxx
{
using System;
}
应用在命名空间里面,和外面区别何在? 为什么部分论者推荐放在命名空间里面呢?
解决方案 »
- 求一思路,关键字:报表,打印,winform
- .dat文件传输过来后,将其中的内容传到数据库中
- 变量名与控件名的问题。。。
- 有懂网站开发的吗?ASP.NET中水印功能在本地可以显示。为什么上了服务器就显示不出来了呢。????
- c#每单击一次button上方的lable控件内容变化,不光是内容变化,如何实现.text的颜色也变化?
- 讨论:struct 和 class的异同。
- 我想用c#三层结构的oa换c#三层结构的全站程序学习。
- 各位高手,问两个简单的问题
- 万分火急!!!关于DateTime
- C#能做成软件发行吗?
- 谁给我讲下 Label控件中 的Text的属性是什么原理做的?
- 请问数据库连接语句放在哪里呢,VS05的
using System;
namespace Outer.Inner{ class Foo { static void Bar() { double d = Math.PI;
} }}
//Now imagine that someone adds another file (File2.cs) to the project that looks like this:
// File2.cs
namespace Outer{ class Math { }}
The compiler searches Outer before looking at those using statements
outside the namespace, so it finds Outer.Math instead of System.Math. Unfortunately (or perhaps fortunately?),
Outer.Math has no PI member, so File1 is now broken. This changes if you put the using inside your namespace declaration, as follows: // File1b.cs
namespace Outer.Inner{ using System; class Foo { static void Bar() {
double d = Math.PI; } }}
Now the compiler searches System before searching Outer, finds System.Math,
and all is well.
Some would argue that Math might be a bad name for a user-defined class, since there's already one in System;
the point here is just that there is a difference, and it affects the maintainability of your code. It's also interesting to note what happens if Foo is in namespace Outer, rather than Outer.Inner. In that case,
adding Outer.Math in File2 breaks File1 regardless of where the using goes. This implies that the compiler
searches the innermost enclosing namespace before it looks at any using statements.
设计器都打不开设计器无法处理第 32 行的代码: this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; 方法“InitializeComponent”内的代码由设计器生成,不应手动修改。请移除任何更改,然后尝试重新打开设计器。
隐藏 编辑