2011-12-31 37 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

相關問題