Can we have same delegate for two events ? which have same number of input parameters? or delegate and the events have one to one relation ?
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Sure, many events use the EventHandler as simple delegate.
Or do you mean, that you can subscribe many events to the same Method? That’s possible too, you can subscribe e.g. subscribe TextChanged-Events from all Textboxes to the same Delegate. Especially for Validating and Validated events it is usefull to use only one method for all fields that utilize the same validating logic.
Events are generally multicast in .NET, so you can subscribe many delegates to one event. For example you can specify two or three validating methods for text fields, and subscribe the TextBox.Validating event to all methods that validate one aspect of the input.