Why can't my public class extend an internal class?

前端 未结 5 1621
猫巷女王i
猫巷女王i 2020-12-01 07:16

I really don\'t get it.

If the base class is abstract and only intended to be used to provide common functionality to public subclasses defined in the assembly, why

5条回答
  •  误落风尘
    2020-12-01 07:54

    I think this would violate the Liskov Substitution Principle.

    In cases like this, I have used internal classes and prefer composition over inheritance. Is there anything about your design that prohibits containing all such functionality in your internal class, and then have your public classes contain an instance of this internal class?

提交回复
热议问题