Reputation:
How can an access specifier to the member of interface be specified?
We can use interface as in two ways
In this way of implementation
protected access specifier is applied only to the events which are in inheritance relationship (IsA).
public access specifier is applied to the properties which are generally used as Has A relation (containment).
thz.. dinesh..
Upvotes: 0
Views: 363
Reputation: 8357
Interface members have the same access operator as the interface they're in, that's the point of having an interface. Otherwise you'd have a public interface IFoo, which has an internal member Bar, which would be problematic if code wants to program against IFoo: it can't always access Bar, although it can use IFoo: the type implementing IFoo apparently doesn't implement Bar at that point.
So if you want to have some elements internal for example, use an internal interface for those members.
Upvotes: 3
Reputation: 58743
All interface members are automatically public.
If inheritance and protected members are your goal, inherit from a base class instead. If composition is your goal, use interfaces.
Upvotes: 4