using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using _16命名空间.hr;
using System.Collections; //如果要使用的类和当前的类不在同一个namespace中,则需要using引用的
//using _Person;
/* 命名空间
* namespace(命名空间),用于解决类重名问题,可以看做是"类的文件夹"
* 在代码中使用其他类的时候需要using类所在的namespace. System.Collections.ArrayList,快速引入的方法,右键->解析
* 为什么使用Convert Console等类不需要自己写using?
* 如果代码和被使用的类在一个namespace则不需要using
* 可以修改默认的namespace,因此不要认为在相同文夹下就不用using,不在相同文件下就需要using
*/
namespace _16命名空间
{
class Program
{
static void Main(string[] args)
{
Person p = new Person();
p.SayHello();
//不同命名空间中的函数调用
_Person.Person pp = new _Person.Person();
//就像文件的全路径一样
pp.SayHello();
//读取命名空间在不同的目录下
_16命名空间.hr.Person hr = new _16命名空间.hr.Person();
hr.SayHello();
Dog d = new Dog();
d.SayHello();
ArrayList list = new ArrayList();
Console.ReadKey();
}
}
class Person
{
public void SayHello()
{
Console.WriteLine("我的命名空间是:16命名空间, 类名是:Person");
}
}
}