2011-12-31 44 views
0

检查这个简单的例子:如何在存在重名的情况下访问根类?

public class Someone{  // [the:A] 
} 

public class Another{ 
    public class Someone{ // [the:B] 
    } 

    public class DoSomething{ 
     **how can I access Someone in root, which is [the:A]**? 
    } 
} 
+1

在这个例子中没有什么简单的..... – 2011-12-31 21:34:30

+0

:(我可以说,男人 – 2012-01-01 14:42:14

回答

5

使用 “全球::” 关键字,或使用使用;顶部的声明。

global::YourNamespace.Someone 

,或者在你的using语句:

using SomeoneRoot = YourNamespace.Someone; 

,并在有你的命名空间的ambiguation的情况下,全球::关键字可以在那里使用过:

using SomeoneRoot = global::YourNamespace.Someone; 
+0

global :: works,thanks – 2011-12-31 21:19:12

相关问题