Question

I have following code in Program.cs in console application

class Program : IView
{
  private static ViewPresenter _presenter;

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

but I cant pass this to presenter, as Main method is static. Now how could I make this work ?

Was it helpful?

Solution

You have to create an instance of Program. Main is a static method.

class Program : IView {
    private static ViewPresenter _presenter;

    static void Main(string[] args) {
        _presenter = new ViewPresenter(new Program());  
    }
}
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top