I can possibly understand that having EventHandler<T>
is convenient, because you don't need to define new delegates all the time and can't understand why its argument should derive from EventArgs
in .NET. Why are both of these should be used? Is there some additional benefit?
Asked
Active
Viewed 67 times
0

Sergiy Belozorov
- 5,856
- 7
- 40
- 73
-
1Also http://blogs.msdn.com/b/kcwalina/archive/2005/11/18/whyeventargs.aspx – dsolimano Sep 29 '13 at 23:29
-
It is not a requirement, just declare your own delegate type. Do expect somebody to say "huh?" and be sure to help him out by explaining why it was important to you. – Hans Passant Sep 29 '13 at 23:29
-
@HansPassant: It's a requirement in .NET, but not in C# in general. – Sergiy Belozorov Sep 29 '13 at 23:30
-
2No, it is not a requirement in either. – Hans Passant Sep 29 '13 at 23:30
-
From MSDN: "Although the C# language allows events to use any delegate type, the .NET Framework has some stricter guidelines on the delegate types that should be used for events". Maybe I read it wrong, but sounds like a requirement to me. – Sergiy Belozorov Sep 29 '13 at 23:32
-
5guidelines != requirements – p.s.w.g Sep 29 '13 at 23:34
-
@p.s.w.g. Hmm... i was actually confused by "should"... but again it's not "must". I will change the question. – Sergiy Belozorov Sep 29 '13 at 23:34
-
@dsolimano: Agree, it's a duplicate, although the chosen answer on the other question is not trivial to understand. Deanna's answer is better. Also thanks for the link to Krzysztof's blog. – Sergiy Belozorov Sep 29 '13 at 23:38
-
It is indeed IMO, and now it's the highest voted. – dsolimano Sep 29 '13 at 23:52