Is there any way that I can create a new delegate type based on an existing one? In my case, I'd like to create a delegate MyMouseEventDelegate
which would have the same functionality as EventHandler<MouseEventArgs>
.
Why do I want this? To take advantage of compile-time type-checking, of course! This way, I can have two different delegates: MyRightClickHandler
and MyLeftClickHandler
, and never the twain shall be confused - even if they are both functionally identical to EventHandler<MouseEventArgs>
.
Is there syntax to do this sort of thing?
Oh, and code like:
using MyRightClickHandler = EventHandler<MouseEventArgs>
isn't good enough. It doesn't do any type-checking, since it doesn't actually create a new type. And I'd have to paste such a line into every code file in which I would refer to MyRightClickHandler
.