在《C#高级编程(第四版)》的52页,“2.8.2 命名空间的别名”一节中,它特别强调了一点“注意命名空间别名的修饰符是::”,下面还有一个例子:
using Introduction = Wrox.ProCSHarp.Basics;
...
Introduction::NamespaceExample NSEx = 
    new Introduction::NamespaceExample();
...我没有vs2005,但是在vs2003上试验,用::直接不能编译,用.才能编译。
这到底是哪里错了?

解决方案 »

  1.   

    没问题
      
    *****************************************************************************
    欢迎使用CSDN论坛专用阅读器 : CSDN Reader(附全部源代码) 最新版本:20070130http://www.cnblogs.com/feiyun0112/archive/2006/09/20/509783.html
      

  2.   

    在此示例中,命名空间 System 用于包括类 TestClass,因此必须使用 global::System.Console 来引用 System.Console 类,该类被 System 命名空间隐藏。而且,别名 colAlias 用于引用命名空间 System.Collections;因此,将使用此别名而不是命名空间来创建 System.Collections.Hashtable 的实例。C#  复制代码 
    using colAlias = System.Collections;
    namespace System
    {
        class TestClass
        {
            static void Main()
            {
                // Searching the alias:
                colAlias::Hashtable test = new colAlias::Hashtable();            // Add items to the table.
                test.Add("A", "1");
                test.Add("B", "2");
                test.Add("C", "3");            foreach (string name in test.Keys)
                {
                    // Seaching the gloabal namespace:
                    global::System.Console.WriteLine(name + " " + test[name]);
                }
            }
        }
    } 示例输出
      
    A 1
    B 2
    C 3
     
      

  3.   

    Introduction::NamespaceExample NSEx = 
        new Introduction::NamespaceExample();
    ...
    书上是对的
    第四版已经用的2.0语法了
    这个用的是全局空间的一种表示法
    建议要学习2.0的所有语法
    2.0 语法增加了很多
    所以要学习很多