我已经在控制器中创建了一个方法,但我需要调用这个方法到另一个类,我不知道如何调用它。需要调用控制器的动作方法到另一个类在c#mvc
我的示例代码: -
public class ReportController : BaseController
{
private readonly IPermissionService _permissionService;
private readonly ICompaniesService _companyService;
public ReportController(IPermissionService permissionService,
ICompaniesService companyService)
{
this._permissionService = permissionService;
this._companyService = companyService;
}
public void Reporting()
{
// code
}
}
public class Home {
public void Execute()
{
//I need to execute the Reporting method here
}
}
我已经尝试了许多事情,叫我在另一个类的方法方法,但我不能得到它的工作。
'新ReportController()报告();' –
可能的复制。 [如何使C#类中的方法调用另一个?](http://stackoverflow.com/questions/16226444/how-to-make-method-call-another-one-in-classes-c) – Draken
是吗?您可以创建报告方法为静态? – Mukund