Creating Delegate Types from Interface Methods

Does the class designer offer any shortcuts for creating a delegate type based on an interface method



Answer this question

Creating Delegate Types from Interface Methods

  • Viper_zz

    There's no doubting that MSR Cambridge did a fine job designing generics, and I'm glad to see that they were commercialized with .NET 2.0. (I've been waiting for them for years!)

    Expressed in terms of generics, what I'm looking to do is:

    public delegate DelegateType<Interface.Foo> FooDelegateType;

    public static event FooDelegateType FooEvents;

    Specially, I want to avoid the CPM (copy-paste-modify) chore in which I copy a series of interface signatures into delegate type declarations.

    DL


  • ts_nika

    Unfortunatly there is no such shortcut but you could look into using snippets to achieve this.



  • bneat

    Great!

    If i got your question right, microsoft gave us "Generics". I just love it. So, there is a generic event handler:

    EventHandler<EventArgs> eventHandler = new EventHandler<EventArgs>(DoSomething);

    I hope this helps you,

    Regards,



  • sunil2205

    VS2005. I'll be sure to mention that in future postings.
  • Lzitro

    Hi,

    Are you using vs2003 or vs2005



  • Creating Delegate Types from Interface Methods