如何实现MVP在控制台应用程序?
-
22-07-2019 - |
题
我具有以下在控制台应用程序中的Program.cs代码
class Program : IView
{
private static ViewPresenter _presenter;
static void Main(string[] args)
{
_presenter = new ViewPresenter(this);
}
}
,但我不能传递到this
演示者,作为主要的方法是static
。现在,我怎么会做这项工作?
解决方案
您必须创建Program
的一个实例。主要是一个静态方法。
class Program : IView {
private static ViewPresenter _presenter;
static void Main(string[] args) {
_presenter = new ViewPresenter(new Program());
}
}
不隶属于 StackOverflow