0

Is it possible to pass event like parameter of constructor in Application?

I have the error

The event 'SocketIOClient.Client.Message' can only appear on the left hand side of += or -=

class Program
{
    static void Main(string[] args)
    {
        Data D = new Data();
        Application A = new Application(D.socket.Message);
    }
}
public class Data
{
    public Client socket;

    public Data()
    {
        socket = new Client("https://www.google.com.ua/");
    }
}
public class Application
{
    public Application(EventHandler<MessageEventArgs> Message)
    {
    }
}
Wai Ha Lee
  • 8,173
  • 68
  • 59
  • 86
A191919
  • 3,342
  • 7
  • 37
  • 85

1 Answers1

0

Yes you can. In your below code line D.socket.Message has to be a method or property stub that has same signature as the delegate type defined in constructor.

Application A = new Application(D.socket.Message);
Rahul
  • 73,987
  • 13
  • 62
  • 116