Subscribe to event eventhandler delegate from method without parameters

240 views Asked by At

I wanna make subscribtion to the Close event with the method ClearControl. The signature is different, but I don't need arguments from event. Is it possible ?

public event EventHandler Close = delegate { };

public void ClearControl(){}

control1.Close += control2.ClearControl;
1

There are 1 answers

1
Hari Prasad On BEST ANSWER

Method signature has to match with event signature.

if you don't want to use Arguments that's just fine, very normal case.

You can do this to call ClearControl method when Close is being called.

control1.Close += (s,e) => { ClearControl(); }