2013-05-09 45 views
1

我有一個類在我的項目,例如,在課堂上如何別名命名空間

namespace BrightCompany.BigProjects.MyBigProject.ApplicationCodeFolder 
{ 
    public class MyBigProjectsClass 
    { 
     public static string returnStringMethod() 
     { 
      return "Your a Star"; 
     } 
    } 
} 
另一個類我想用這種方法讓說

現在,

namespace BrightCompany.BigProjects.MyBigProject 
{ 
    public class MyBigProjectsClassABC 
    { 
     private void ABC() 
     { 
      string tooLong = BrightCompany.BigProjects.MyBigProject.ApplicationCodeFolder.MyBigProjectsClass.returnStringMethod(); 
     } 
    } 
} 

我怎樣才能長話短說,我試圖把這個,

using BrightCompany.BigProjects.MyBigProject.ApplicationCodeFolder; 

但沒有收穫,只有痛苦!

回答

4

這是語法:

using MyAlias = BrightCompany.BigProjects.MyBigProject.ApplicationCodeFolder; 

雖然,下面還將努力:

using BrightCompany.BigProjects.MyBigProject.ApplicationCodeFolder; 

namespace BrightCompany.BigProjects.MyBigProject 
{ 
    public class MyBigProjectsClassABC 
    { 
     private void ABC() 
     { 
      string tooLong = MyBigProjectsClass.returnStringMethod(); 
     } 
    } 
} 
2

試試這個:

using colAlias = BrightCompany.BigProjects.MyBigProject.ApplicationCodeFolder; 

string tooLong = colAlias::MyBigProjectsClass.returnStringMethod();