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,598
  • 83
  • 57
  • 92
A191919
  • 3,422
  • 7
  • 49
  • 93

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
  • 76,197
  • 13
  • 71
  • 125