6
Reply

Why we can not provide access modifer while declaration interface ?

    because they are all public by default

    An interface describes a group of related functionality for a class or structure. They are automatically public and cannot include access modifiers. It is important to note that interfaces can hold properties, events, and indexers also. The interface is always public because it is a contract to be implemented and the implementer decides what access that particular function should have.

    Because interfaces offer contracts. And the classes MUST implement the interface, so other modifiers could make the contract impossible because of the scope of the class (like internal modifier in different assemblies etc).

    Interface is the standard structure to be followed by the classes where class will implement the functionality and it includes only the declaration of methods,functions and properties.We cannot provide access modifier while declaration of interface bcoz interfaces are public by default and interfaces deals with public members only.

    Hi Santosh,


    Interface have by default Public access modifier so we need not to defined it .and interface take only public access modifier while declaring it.    

    interface just like the abstract class in interface we only declare the methods not implement it


    so for  implementing the interface  we need acess to all the methods of interface. hence by default the acess modifires for the interface is public