I have started working with ASP.NET controls and there appeared a question:
“why events in ASP controls are defined as delegates, and not as methods”?
I have started working with ASP.NET controls and there appeared a question: why events
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.
Because an event must point to the function that it fires somehow and in C# this mechanism is achieved by delegates.
In response to the comment:
Because Java uses the old traditional event pattern (like in C++). C# delegates are easier to use and also allow you to point to a static function rather than forcing the use of a class method.