命名空间别名

 

 

extern alias outer;//必须位于所有的 using 前面

using System;
using FourPerson = 第四章;
using SevenPerson = 第七章._1;



class Person
{
    public int Gid { get; set; }
}

namespace 第七章._1
{

    class Program
    {
        static void Main(string[] args)
        {
            Console.WriteLine("***************限定的命名空间别名***************");

            Console.WriteLine(typeof(FourPerson::Person));//第四章.Person
            Console.WriteLine(typeof(SevenPerson::Person));//第七章._1.Person


            Console.WriteLine("***************全局命名空间别名***************");

            Console.WriteLine(typeof(Person));//第七章._1.Person
            Console.WriteLine(typeof(global::Person));//Person
            Console.WriteLine(typeof(global::第七章._1.Person));//第七章._1.Person


            Console.WriteLine("***************外部别名***************");

            Console.WriteLine(typeof(outer.第二章.Person));//第二章.Person
            Console.WriteLine(typeof(outer.第一章.Person));//第一章.Person

            Console.ReadKey();
        }
    }

    class Person
    {
        public int Pid { get; set; }
    }
}

 

 

posted @ 2018-03-27 00:00  热敷哥  阅读(531)  评论(0编辑  收藏  举报