代码之家  ›  专栏  ›  技术社区  ›  Prashant Cholachagudda

如何在控制台应用程序中实现MVP?

  •  1
  • Prashant Cholachagudda  · 技术社区  · 15 年前

    我在控制台应用程序的program.cs中有以下代码

    class Program : IView
    {
      private static ViewPresenter _presenter;
    
      static void Main(string[] args)
      {
          _presenter = new ViewPresenter(this);  
      }
    }
    

    但我不能通过 this 作为主要方法 static . 现在我该怎么做呢?

    1 回复  |  直到 11 年前
        1
  •  3
  •   Rok StrniÅ¡a    11 年前

    您必须创建 Program . MAIN是一种静态方法。

    class Program : IView {
        private static ViewPresenter _presenter;
    
        static void Main(string[] args) {
            _presenter = new ViewPresenter(new Program());  
        }
    }