Internal abstract class: how to hide usage outside assembly?

后端 未结 7 1071
再見小時候
再見小時候 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:25

    There really isn't much of a benefit to what you're trying to achieve but what you're actually looking to achieve is similar to this.

    Have your abstract base class in 1 assembly with everything internal. In the AssemblyInfo for that assembly you need to add

    [assembly:InternalsVisibleTo("cs_friend_assemblies_2")]
    

    Then in another assembly you have all the classes you want publicly available. Note you will still be able to access the base class from intellisense for any code inside cs_friend_assemblies_2 or whatever you name your assembly but not any where else.

提交回复
热议问题