Internal abstract class: how to hide usage outside assembly?

后端 未结 7 1064
再見小時候
再見小時候 2020-12-05 01:30

I have a common assembly/project that has an abstract base class, then several derived classes that I want to make public to other assemblies.

I don\'t want the abs

7条回答
  •  再見小時候
    2020-12-05 02:24

    Will the other assemblies ever inherit from your abstract base class or any of the public classes that do inherit from your abstract base class?

    If so, you have to make the abstract base class public. Just make methods you don't want visible outside the assembly internal.

    If not, maybe interfaces can help? Define public interfaces, make your public classes implement them, and provide a factory to get instances. That way the only thing intellisense sees outside the assembly is the interface.

    Does that help?

提交回复
热议问题