Hello everyone,
I understand in the rule of C#, we are not allowed to add public/private/protected qualifier to methods in interface. My question is why adding the qualifiers are not allowed? I want to know the reason behind the claimed rule, i.e. what issues will be if we are allowed to add qualifier?
thanks in advance,
George
Bechir BejaouiPosted Oct 31, 2008, 8:07 PM
private: only visible inside a unique class
protected: only visible inside the class and the derived types
public: visible by different types
George GeorgePosted Oct 30, 2008, 9:16 AM
Can you show me how to make a method of an interface private please? I am confused and I tried seems we can not.
regards,
George
Bechir BejaouiPosted Oct 30, 2008, 7:27 AM
2. For the second question, I thing if you have to use protected keyword then abstract class is the best solution. To be more clear, the interface concept is used only for contracts context and not for implementation context
George GeorgePosted Oct 27, 2008, 7:40 AM
Thanks.
1.
I can understand that you mean if interface method is marked as private, then the implementation must be private and the implementation could not be accessed from outside? Is that your point?
2.
My confusion is what do you mean "if they are marked as protected will do not make sens as the interface contains only methods contracts and not implementations going to be modified"? Could you show some pseudo code to describe your ideas please?
regards,
George
Bechir BejaouiPosted Oct 27, 2008, 6:34 AM
if they are marked as private so they could'nt be viewed ouside the interface scoop on one hand
in the other hand, if they are marked as protected will do not make sens as the interface contains only methods contracts and not implementations going to be modified