您的位置:首页 > 其它

看到这样的 语句colAlias::Hashtable 你别晕( 命名空间别名限定符)

2011-12-01 11:08 337 查看
我一直看到这样的语句就感觉头疼,这个东西到底是神马意思呢?

今天msdn了一下原来这个东西学名 命名空间别名限定符

当成员可能被同名的其他实体隐藏时,可以使用这种方式。

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]);
}
}
}
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐