I have a little problem understanding delegates.
I have a delegate that I will call when I enter the y character:
public delegate void respondToY(string msgToSend); private respondToY yHandler;
I have a subscription method so that the calling code can request a notification when a delegate is called:
public void Subscribe(respondToY methodName) { yHandler += methodName; }
As far as I can see, in order to register with this delegate, I need to provide something like responseToY. However, when I call the subscription method, I can provide either a new delegate instance or just the name of the method. Does this mean that any method that matches the signature of the delegate can be used and will be automatically converted to the correct delegate type?
** Change **
Thus, under this assumption, it would be fair to specify only the name of the method for such things as click event handlers for buttons (assuming the method took the sender and the corresponding event object), will it be converted to the required delegate?
c # delegates
richzilla
source share