Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. Events in an interface

Events in an interface

Scheduled Pinned Locked Moved C#
question
4 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • J Offline
    J Offline
    jdkulkarni
    wrote on last edited by
    #1

    One simple question, if an event is declared like a field of delegate type, except that the keyword event precedes the event declaration how can an interface contain a type declaration? Jayant D. Kulkarni

    S 1 Reply Last reply
    0
    • J jdkulkarni

      One simple question, if an event is declared like a field of delegate type, except that the keyword event precedes the event declaration how can an interface contain a type declaration? Jayant D. Kulkarni

      S Offline
      S Offline
      Stefan Troschuetz
      wrote on last edited by
      #2

      jdkulkarni wrote:

      how can an interface contain a type declaration?

      It can't. An interface can only contain signatures of the following members: Methods, Properties, Indexers and Events. (interface (C# Reference)[^]


      "Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning." - Rick Cook

      www.troschuetz.de

      J 1 Reply Last reply
      0
      • S Stefan Troschuetz

        jdkulkarni wrote:

        how can an interface contain a type declaration?

        It can't. An interface can only contain signatures of the following members: Methods, Properties, Indexers and Events. (interface (C# Reference)[^]


        "Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning." - Rick Cook

        www.troschuetz.de

        J Offline
        J Offline
        jdkulkarni
        wrote on last edited by
        #3

        Yes, thats right. But I can not have delegate void MyDelegate(); but I can have event MyDelegate MyEvent; I am asking @ this scenario.

        Jayant D. Kulkarni Brainbench Certified Software Engineer in C#, ASP.NET, .NET Framework and ADO.NET

        S 1 Reply Last reply
        0
        • J jdkulkarni

          Yes, thats right. But I can not have delegate void MyDelegate(); but I can have event MyDelegate MyEvent; I am asking @ this scenario.

          Jayant D. Kulkarni Brainbench Certified Software Engineer in C#, ASP.NET, .NET Framework and ADO.NET

          S Offline
          S Offline
          Stefan Troschuetz
          wrote on last edited by
          #4

          jdkulkarni wrote:

          But I can not have delegate void MyDelegate(); but I can have event MyDelegate MyEvent; I am asking @ this scenario.

          And you have (more or less) already answered yourself. The first is simply not possible, since an interface can only contain signatures of the following members: Methods, Properties, Indexers and Events; and this delegate void MyDelegate(); declares a type that references a method.


          "Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning." - Rick Cook

          www.troschuetz.de

          1 Reply Last reply
          0
          Reply
          • Reply as topic
          Log in to reply
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes


          • Login

          • Don't have an account? Register

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • World
          • Users
          • Groups