我的项目中有一个班级,例如,
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;
但没有收获,ONLy痛苦!
答案 0 :(得分: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();
}
}
}
答案 1 :(得分:2)
试试这个:
using colAlias = BrightCompany.BigProjects.MyBigProject.ApplicationCodeFolder;
string tooLong = colAlias::MyBigProjectsClass.returnStringMethod();