user11224591
user11224591

Reputation:

default access modifier for interface member

I'm new to C#, just a question on default access modifier for interface member. We know that the default access modifier for interface is "internal", but why the default access modifier for interface member is "public"? shouldn't it be "internal" so it can be consistent?

Upvotes: 0

Views: 419

Answers (1)

Ahmed Yousif
Ahmed Yousif

Reputation: 2348

Interfaces declared directly within a namespace can be declared as public or internal and, just like classes and structs, interfaces default to internal access. Interface members are always public because the purpose of an interface is to enable other types to access a class or struct. No access modifiers can be applied to interface members.

For more information about Access Modifiers (C# Programming Guide) check the following link

Upvotes: 1

Related Questions