1. 程式人生 > >7.4 命名空間別名

7.4 命名空間別名

7.4.1 限定的命名空間別名

 1 using WinForm = System.Windows.Forms;
 2 
 3 namespace Test01
 4 {
 5     class WinForm { }
 6     class Program
 7     {
 8         static void Main(string[] args)
 9         {
10             Console.WriteLine(typeof(WinForm::Button));
11             Console.ReadKey();
12 } 13 } 14 }

7.4.2 全域性命名空間別名

 1 using System;
 2 class Configuration { }
 3 namespace Test01
 4 {
 5     class Configuration { }
 6     class Program
 7     {
 8         static void Main(string[] args)
 9         {
10             Console.WriteLine(typeof(Configuration));
11 Console.WriteLine(typeof(global::Configuration)); 12 Console.WriteLine(typeof(global::Test01.Configuration)); 13 Console.ReadKey(); 14 /* 15 Test01.Configuration 16 Configuration 17 Test01.Configuration 18 */
19 } 20 } 21 }