( 第 3/3 节 )
1在全局下自定义一个命名空间(如MySpace,与入口函数 Main 不在同一命名空间中),里面定义一个空类,没有任何自定义成员。在入口的 Main函数中创建一个实例,实例来自指定自定义命名空间(如MySpace)的类
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {
            MySpace.TestClass t = new MySpace.TestClass();
        }
    }
}
namespace MySpace
{
    class TestClass
    { }
}2接上题,由显示引用命名空间里的类,改为通过 using 关键字引用
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using MySpace;
namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {
            TestClass t = new TestClass();
        }
    }
}
namespace MySpace
{
    class TestClass
    { }
}3接第一题,给自定义命名空间起个别名
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using MyAlias = MySpace;
namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {
            MyAlias.TestClass t = new MyAlias.TestClass();
        }
    }
}
namespace MySpace
{
    class TestClass
    {
    }
}4接第一题,给自定义命名空间中的类起个别名,并在主函数中用别名引用
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using MyClass = MySpace.TestClass;
namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {
            MyClass t = new MyClass();
        }
    }
}
namespace MySpace
{
    class TestClass
    {
    }
}5在全局下自定义一个命名空间(如Leval1,与入口函数 Main 不在同一命名空间中),再在其中定义一个子命名空间,里面定义一个空间(如Leval2),在子空间中定义一个空类,没有任何自定义成员。在入口的 Main 函数中创建一个实例,实例来自指定自定义命名空间(如Leval2)的类
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {
            level1.level2.TestClass t = new level1.level2.TestClass();
        }
    }
}
namespace level1
{
    namespace level2
    {
        class TestClass
        {
        }
    }
    
}    