Click here to Skip to main content
15,895,799 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
SQL
Hi ,

 As we know Interface in C#. Its accessmodifier is Public by default. My question is why we wont use private or protected as access modifier in Interface. Please reply me with example.
Posted

1 solution

Because, roughly speaking, an interface abstracts the actual implementation, while private and protected access modifiers typically pertain the very implementation.
The interface is a contract, hence it has to be fully accessible.
 
Share this answer
 
Comments
kamalsekhar 4-Jun-14 6:16am    
Hi CPallini,
I did not understand properly. Can you please explain me clearly and one more thing, if we can use private and protected in interface in c#, How to use, please give me solution with example.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900