Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

Required fields*

21
  • 34
    +1 for the theoretical scenario of "affected by an infinite amount of code" Commented Mar 11, 2016 at 13:53
  • 13
    Perhaps worth noting as well that the C# designers actually decided to prohibit overriding an inherited method unless it's explicitly marked as virtual, for the reasons outlined in this answer. Commented Mar 11, 2016 at 15:05
  • 11
    Or put simply: protected is for methods, not for data members. Commented Mar 11, 2016 at 15:35
  • 7
    I can't find it now, but I remember reading a well written answer from @EricLippert about why MS sealed big parts of .net's library and IIRC why he'd've liked to've locked the rest up. The moment you allow 3rd party inheritors to start touching internal values you need to add a huge amount of validation/sanity checks to every method because you can no longer trust any design invariants about the objects internal state. Commented Mar 11, 2016 at 16:05
  • 4
    @ThorbjørnRavnAndersen "while developing but not when released" - how on earth is a class supposed to know? Do you really want to compile a test version that is different from the released version when you can't even test the release version? Tests shouldn't need to access private stuff anyway. Commented Mar 14, 2016 at 7:51