[摘自c#Bible]c#中namespace的使用(命名空间)
The C# classes that you design will be used by code that you write and possibly by code that
other people write. Your C# classes may be used by a VB.NET application or from within an
ASP.NET page. Moreover, your classes may very well be used alongside other classes
designed by other .NET developers.
Code written in a .NET language references classes by their names, and all of these classes
used together suggests an obvious dilemma: What happens if a developer wants to use two
classes that have the same name?
Suppose you write a C# class that reads records from a database and you name the class
Recordset. Code that wants to use your class may create objects as follows:
Recordset MyRecordset = new Recordset();
Now suppose that you package your classes into a .NET assembly and distribute your
assembly for use by other applications. Furthermore, suppose that someone obtains your
assembly and integrates it into his or her application. What happens if that same application
also makes use of another assembly written by someone else, which also contains a class
called Recordset? When the application code creates a new Recordset object, which class is
used to create the object: yours or the class in the other assembly?
This problem can be solved through the C# concept of name-spaces. Namespaces organize
classes under a named group, and the namespace name can be used to help distinguish
between two classes with the same name. Your C# code should use namespaces to help
further identify your classes under a common grouping, especially if you are planning to build
an assembly for use by other developers. Namespaces may even come in handy in C#
applications that you build, because your C# applications may use an external assembly that
uses class names which mirror yours.
Declaring a Namespace
You declare a namespace with the C# namespace keyword. A namespace identifier and curly
brackets follow the namespace keyword. Classes to be included in the namespac
相关文档:
C++中的Static有两个作用。
1、 静态局部变量
静态局部变量在函数内定义 它的生存期为整个源程序,但是其作用域在该函数内,只能在定义该变量的函数内使用该变量。 允许对构造类静态局部量赋初值,若未赋以初值,则由系统自动赋以0值。
void fun1()
{
static int i = 0;
......
C语言必知必会
指针:
1.指针声明后要赋值!否则是空指针,可不知道指向了哪里
例如:
void swap(int *a,int *b){
int *tmp;
*tmp=*a;
*a=*b;
*b=*tmp;
}
本来是想利用上面的swap函数实现两个数的互换,但是*tep=*a;这句话是有误的 ......
本文触及到Socket TCP/IP编程方面的知识,其实这是很简单的内容,大家看不明的地方大可以先往下读,以后再看一遍,可能会觉得很简单。
很多人写网站用惯了IIS和Tomcat这些高级的后台来做网站后台服务,然而,在这些后台还没有问世之前,人们是怎么编写网站的呢?他们底层共同遵守的准则和标准又是什么呢?
这就是ht ......
微软在其.net战略中,对其主推的Web Service做了大肆的宣扬。现在,Web
Service正如火如荼地发展着,相关的各项新技术层出不穷。Web
Service的发展正构筑着互联网时代美好的明天。在本文中,我将向大家介绍Web Service的一些基本知识、如何用C#建立一个Web
Service。通过文章,我们还将对WSDL、UDDI以及未来的Web ......
1. 简述 private、 protected、 public、 internal 修饰符的访问权限。答 . private : 私有成员, 在类的内部才可以访问。 protected : 保护成员,该类内部和继承类中可以访问。 public : 公共成员,完全公开,没有访问限制。 internal: 在同一命名空间内可以访问。2 .列举ASP.NET 页面之间传递值的几种方式。 答. ......