locked
Why must an C# interface method implemented in a class be public? RRS feed

Answers

  • User968318577 posted

    Thanks for the reply Mike,this answer is also considerable but what i think is ,

    we cannot have private method(only those declared inside interface) inside class inheriting interfaces is as interfaces are designed as contract and for exposing the properties of the class it inherits to outside world

    and if we will make the methods private then those methods will not be accessed by any other class that is completely against the why interface are build................

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Monday, July 7, 2014 4:47 AM

All replies

  • User-821857111 posted

    Why don't you just read the answer to the question on Stackoverflow where you copied the question from?

    Monday, July 7, 2014 2:51 AM
  • User968318577 posted

    Thanks for the suggestion Mike,Actually i was searching for the same and but the answer explained there does not satisfied me , as of now thats why i have copied the question from there into this forum can you please explain in brief, why its not public .

    Thanks In Advance..........

    Monday, July 7, 2014 3:13 AM
  • User968318577 posted

    Thanks for the reply Mike,this answer is also considerable but what i think is ,

    we cannot have private method(only those declared inside interface) inside class inheriting interfaces is as interfaces are designed as contract and for exposing the properties of the class it inherits to outside world

    and if we will make the methods private then those methods will not be accessed by any other class that is completely against the why interface are build................

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Monday, July 7, 2014 4:47 AM
  • User-821857111 posted

    That's pretty much what Jon Skeet said in the second answer.

    Monday, July 7, 2014 5:42 AM