Hiding inherited members

前端 未结 9 1927
北海茫月
北海茫月 2020-12-03 09:52

I\'m looking for some way to effectively hide inherited members. I have a library of classes which inherit from common base classes. Some of the more recent descendant clas

9条回答
  •  南笙
    南笙 (楼主)
    2020-12-03 10:08

    While you cannot prevent usage of those inherited members to my knowledge, you should be able to hide them from IntelliSense using the EditorBrowsableAttribute:

    Using System.ComponentModel;
    
    [EditorBrowsable(EditorBrowsableState.Never)]
    private string MyHiddenString = "Muahahahahahahahaha";
    

    Edit: Just saw this in the documentation comments, which makes it kinda useless for this purpose:

    There is a prominent note that states that this attribute "does not suppress members from a class in the same assembly". That is true but not complete. Actually, the attribute does not suppress members from a class in the same solution.

提交回复
热议问题