Reputation: 25
So I've had an argument with a friend, basically he is saying that this an event handler and I am stating that this is a method. Can you please tell me who's right, and explain what makes this an event handler, if so?
Control ctrlClick;
private void NextColour(object sender)
{
ctrlClick = sender as Control;
// More Code Here
}
Upvotes: 1
Views: 1499
Reputation: 369
An event handler is a method subscribed to an event, and as it's name implies it gets called back in order to handle the occurrence of the event,once it gets notified by the event publishing mechanism. If the method has not been subscribed to handle an event, then there is no event for it handle, meaning it's just a method ( maybe a very important one ... :) but still just a method).
Upvotes: 1
Reputation: 101731
Did you subscribe this method to an event like someEvent += NextColour;
? Then it's an event handler. Otherwise just a method.
Upvotes: 2