I am talking about the common signature for events:
Event ( object, args );
and why not:
Event ( ImageProcessor, args );
Is #1 incurs a performance cost too, along with being unclear?
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.
I think it’s because of historical reasons mixed with avoiding code duplication.
In .Net 1.0 there was no generics, so for each type that can throw event you was forced to define the event handler delegate.
like:
so instead of this, freamework developers created one
and used cast/as operators.
From .Net 2.0 we have generics so you can define it once like this
or even
And then use like this.
But this would break all applications written for .Net 1.0/1.1 so instead framework developers leaved it as it was. And now everyone are using those pre-generics classes.
Also I’m not sure if Windows Forms designer can hadle generic EventHandler. I’ve never tried to test it.
In my opinion typed (generic) events are better than this standard. So use it where you can.