1

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

class Program : IView
{
  private static ViewPresenter _presenter;

  static void Main(string[] args)
  {
      _presenter = new ViewPresenter(this);  
  }
}

但我不能传递this给演示者,因为 Main 方法是static. 现在我怎么能做这个工作?

4

1 回答 1

3

您必须创建一个Program. Main 是一个静态方法。

class Program : IView {
    private static ViewPresenter _presenter;

    static void Main(string[] args) {
        _presenter = new ViewPresenter(new Program());  
    }
}
于 2009-09-18T15:05:35.083 回答