In my class I want to declare an event that other classes can subscribe to. What is the correct way to declare the event?
This doesn’t work:
public event CollectMapsReportingComplete;
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.
You forgot to mention the type. For really simple events,
EventHandlermight be enough:Sometimes you will want to declare your own delegate type to be used for your events, allowing you to use a custom type for the
EventArgsparameter (see Adam Robinson’s comment):You can also use the generic
EventHandlertype instead of declaring your own types: