コンソールアプリケーションにMVPを実装する方法
-
22-07-2019 - |
質問
コンソールアプリケーションのProgram.csに次のコードがあります
class Program : IView
{
private static ViewPresenter _presenter;
static void Main(string[] args)
{
_presenter = new ViewPresenter(this);
}
}
しかし、Mainメソッドは static
なので、 this
をプレゼンターに渡すことはできません。さて、どうすればこの作品を作ることができますか?
解決
Program
のインスタンスを作成する必要があります。 Mainは静的メソッドです。
class Program : IView {
private static ViewPresenter _presenter;
static void Main(string[] args) {
_presenter = new ViewPresenter(new Program());
}
}
所属していません StackOverflow