Interface? RRS feed

  • Question

  • Hi guys,

    Please see code belown.

    interface IMyI
           void AskPass();//But here is no public modifier

    class SomeClass: IMyI
            static void Main(string[] args)
            void AskPass()//it was giving this error " cannot implement an interface member because it is not public. " untill i put here public modifier. is this normal?



    Wednesday, March 7, 2012 7:18 AM


  • Yes. That is a rule. A member of an interface is always public. That is why we cannot specify access specifiers like public or private to interface members. And a class implementing an interface should declare the implemented methods to be public.

    Please mark this post as answer if it solved your problem. Happy Programming!

    • Proposed as answer by Kris444 Wednesday, March 7, 2012 7:52 AM
    • Marked as answer by Lisyus35 Wednesday, March 7, 2012 8:00 AM
    Wednesday, March 7, 2012 7:24 AM