Protected/Private Interface

Last post 08-29-2008 5:44 AM by kamii47. 3 replies.

Sort Posts:

  • Protected/Private Interface

    08-29-2008, 3:56 AM
    • Member
      13 point Member
    • spillbean
    • Member since 08-08-2007, 1:04 PM
    • Posts 49

    Hi Guys, We all know that  Interface members are by default  Public and Abstract. But can we declare Interface as private or protected ?

    If yes then what is the significance of Private Interface and is there any difference in implementation of Protected and Public Interfaces?

    Filed under: , , ,
  • Re: Protected/Private Interface

    08-29-2008, 5:20 AM
    • Star
      9,462 point Star
    • kamii47
    • Member since 05-26-2005, 12:04 PM
    • Karachi, Pakistan
    • Posts 2,198
    No you can't declare interface members as private or protected.
    Kamran Shahid
    Sr. Software Engineer
    (MCP,MCAD.net,MCSD.net,MCTS,MCPD.net[web])

    Remember to click "Mark as Answer" on the post that helps U
  • Re: Protected/Private Interface

    08-29-2008, 5:21 AM
    Answer
    • Star
      7,995 point Star
    • MelvynHarbour
    • Member since 06-06-2008, 9:33 AM
    • Cambridge, UK
    • Posts 1,288

    Interface members aren't 'public' or 'abstract'. They are just interface members. They're part of a contract. You can't set accessibility modifiers on interface members at all. Try it and you'll see the compiler errors!

  • Re: Protected/Private Interface

    08-29-2008, 5:44 AM
    Answer
    • Star
      9,462 point Star
    • kamii47
    • Member since 05-26-2005, 12:04 PM
    • Karachi, Pakistan
    • Posts 2,198

    Interface members are default implicitly public as all methods/properties e.t.c have to be implemented to the classes which inherited from it.

    [As all have to be implmented so all are abstract] 

    An Interface is a reference type and it contains only abstract members. Interface's members can be Events, Methods, Properties and Indexers. But the interface contains only declaration for its members. Any implementation must be placed in class that realizes them. The interface can't contain constants, data fields, constructors, destructors and static members. All the member declarations inside interface are implicitly public.

    check http://www.codersource.net/csharp_tutorial_interface.html 

    and http://forums.msdn.microsoft.com/en-US/netfxbcl/thread/55256ccb-3725-41c7-bc58-a7e05b3c0db9/ 

    Kamran Shahid
    Sr. Software Engineer
    (MCP,MCAD.net,MCSD.net,MCTS,MCPD.net[web])

    Remember to click "Mark as Answer" on the post that helps U
Page 1 of 1 (4 items)
Microsoft Communities